chore(@desktop/wallet): Simplify the wallet networks service
fixes #12717
This commit is contained in:
parent
d9945b39dc
commit
5473e3b14e
|
@ -43,10 +43,10 @@ proc getIndex*(self: Controller, address: string): int =
|
|||
return self.walletAccountService.getIndex(address)
|
||||
|
||||
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] =
|
||||
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 =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
|
|
@ -713,9 +713,9 @@ proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int,
|
|||
let token = self.tokenService.findTokenBySymbol(symbol)
|
||||
if token != nil:
|
||||
for addrPerChain in token.addressPerChainId:
|
||||
# depending on areTestNetworksEnabled (in getNetwork), contractAddresses will
|
||||
# depending on areTestNetworksEnabled (in getNetworkByChainId), contractAddresses will
|
||||
# contain mainnets or testnets only
|
||||
let network = self.networkService.getNetwork(addrPerChain.chainId)
|
||||
let network = self.networkService.getNetworkByChainId(addrPerChain.chainId)
|
||||
if network == nil:
|
||||
continue
|
||||
contractAddresses[addrPerChain.chainId] = addrPerChain.address
|
||||
|
|
|
@ -372,8 +372,8 @@ proc getCommunityTokens*(self: Controller, communityId: string): seq[CommunityTo
|
|||
proc getAllCommunityTokens*(self: Controller): seq[CommunityTokenDto] =
|
||||
self.communityTokensService.getAllCommunityTokens()
|
||||
|
||||
proc getNetwork*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetwork(chainId)
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getTokenBySymbolList*(self: Controller): seq[TokenBySymbolItem] =
|
||||
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) =
|
||||
self.communityService.deleteCommunityChat(communityId, channelId)
|
||||
|
||||
proc getNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networksService.getNetworks()
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networksService.getCurrentNetworks()
|
||||
|
||||
proc promoteSelfToControlNode*(self: Controller, communityId: string) =
|
||||
self.communityService.promoteSelfToControlNode(communityId)
|
||||
|
|
|
@ -613,7 +613,7 @@ proc buildTokensAndCollectiblesFromWallet(self: Module) =
|
|||
var tokenListItems: seq[TokenListItem]
|
||||
|
||||
# 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 filteredChains = t.addressPerChainId.filter(apC => allNetworks.contains(apc.chainId))
|
||||
return filteredChains.len != 0
|
||||
|
|
|
@ -159,8 +159,8 @@ proc findContractByUniqueId*(self: Controller, contractUniqueKey: string): Commu
|
|||
proc computeBurnFee*(self: Controller, contractUniqueKey: string, amount: Uint256, addressFrom: string, requestId: string) =
|
||||
self.communityTokensService.computeBurnFee(contractUniqueKey, amount, addressFrom, requestId)
|
||||
|
||||
proc getNetwork*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetwork(chainId)
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getOwnerToken*(self: Controller, communityId: string): CommunityTokenDto =
|
||||
return self.communityTokensService.getOwnerToken(communityId)
|
||||
|
|
|
@ -299,11 +299,11 @@ method computeBurnFee*(self: Module, contractUniqueKey: string, amount: string,
|
|||
self.controller.computeBurnFee(contractUniqueKey, amount.parse(Uint256), addressFrom, requestId)
|
||||
|
||||
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: ""
|
||||
|
||||
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: ""
|
||||
|
||||
method onCommunityTokenDeployStateChanged*(self: Module, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) =
|
||||
|
|
|
@ -573,8 +573,8 @@ proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string
|
|||
proc getRemoteDestructedAmount*(self: Controller, chainId: int, contractAddress: string): Uint256 =
|
||||
return self.communityTokensService.getRemoteDestructedAmount(chainId, contractAddress)
|
||||
|
||||
proc getNetwork*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetwork(chainId)
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getAppNetwork*(self:Controller): NetworkDto =
|
||||
self.networksService.getAppNetwork()
|
||||
|
|
|
@ -266,7 +266,7 @@ method onAppNetworkChanged*[T](self: Module[T]) =
|
|||
self.view.emitAppNetworkChangedSignal()
|
||||
|
||||
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 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)
|
||||
|
@ -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 =
|
||||
# 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 ownerAddressName = if len(tokenDto.deployer) > 0: self.controller.getCommunityTokenOwnerName(tokenDto.deployer) else: ""
|
||||
|
||||
|
|
|
@ -102,10 +102,10 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
|
|||
self.walletAccountService.getWalletAccounts(true)
|
||||
|
||||
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] =
|
||||
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) =
|
||||
self.settingsService.setSocialLinks(links)
|
||||
|
|
|
@ -41,7 +41,7 @@ proc init*(self: Controller) =
|
|||
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
proc getNetworks*(self: Controller): seq[CombinedNetworkDto] =
|
||||
proc getCombinedNetworks*(self: Controller): seq[CombinedNetworkDto] =
|
||||
return self.networkService.getCombinedNetworks()
|
||||
|
||||
proc areTestNetworksEnabled*(self: Controller): bool =
|
||||
|
|
|
@ -41,7 +41,7 @@ method getModuleAsVariant*(self: Module): QVariant =
|
|||
method refreshNetworks*(self: Module) =
|
||||
var items: seq[Item] = @[]
|
||||
var combinedItems: seq[CombinedItem] = @[]
|
||||
for n in self.controller.getNetworks():
|
||||
for n in self.controller.getCombinedNetworks():
|
||||
var prod = newItem(
|
||||
n.prod.chainId,
|
||||
n.prod.layer,
|
||||
|
|
|
@ -40,7 +40,7 @@ proc deleteAccount*(self: Controller, address: string) =
|
|||
self.walletAccountService.deleteAccount(address)
|
||||
|
||||
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 =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
|
|
@ -50,7 +50,7 @@ proc getWalletAddresses*(self: Controller): seq[string] =
|
|||
return self.walletAccountService.getWalletAddresses()
|
||||
|
||||
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) =
|
||||
self.collectibleService.updateCollectiblePreferences(tokenPreferencesJson)
|
||||
|
|
|
@ -35,7 +35,7 @@ proc init*(self: Controller) =
|
|||
discard
|
||||
|
||||
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 =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
|
|
@ -54,14 +54,14 @@ proc getCurrencyAmount*(self: Controller, amount: float64, symbol: string): Curr
|
|||
proc updateCurrency*(self: Controller, currency: string) =
|
||||
self.walletAccountService.updateCurrency(currency)
|
||||
|
||||
proc getNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networkService.getNetworks()
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networkService.getCurrentNetworks()
|
||||
|
||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
return self.walletAccountService.getWalletAccounts()
|
||||
|
||||
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 =
|
||||
return self.walletAccountService.getKeypairByAccountAddress(address)
|
||||
|
|
|
@ -46,7 +46,7 @@ proc removeAddress*(self: Filter, address: string) =
|
|||
|
||||
proc updateNetworks*(self: Filter) =
|
||||
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) =
|
||||
self.setFillterAllAddresses()
|
||||
|
|
|
@ -88,9 +88,6 @@ method onAddAccountModuleLoaded*(self: AccessInterface) {.base.} =
|
|||
method destroyAddAccountPopup*(self: AccessInterface) {.base.} =
|
||||
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.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -413,9 +413,6 @@ method getAddAccountModule*(self: Module): QVariant =
|
|||
method onAddAccountModuleLoaded*(self: Module) =
|
||||
self.view.emitDisplayAddAccountPopup()
|
||||
|
||||
method getNetworkLayer*(self: Module, chainId: int): string =
|
||||
return self.networksModule.getNetworkLayer(chainId)
|
||||
|
||||
method getLatestBlockNumber*(self: Module, chainId: int): string =
|
||||
return self.transactionService.getLatestBlockNumber(chainId)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ proc init*(self: Controller) =
|
|||
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
proc getFlatNetworks*(self: Controller): seq[NetworkDto] =
|
||||
proc getFlatNetworks*(self: Controller): var seq[NetworkDto] =
|
||||
return self.networkService.getFlatNetworks()
|
||||
|
||||
proc setNetworksState*(self: Controller, chainIds: seq[int], enabled: bool) =
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
import app_service/service/network/dto
|
||||
|
||||
type
|
||||
NetworksDataSource* = tuple[
|
||||
getFlatNetworksList: proc(): var seq[NetworkDto]
|
||||
]
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## 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.} =
|
||||
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")
|
||||
|
|
|
@ -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
|
|
@ -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 ./item
|
||||
import app_service/service/network/dto
|
||||
import ./io_interface
|
||||
|
||||
const EXPLORER_TX_PREFIX* = "/tx/"
|
||||
|
||||
|
@ -25,34 +25,30 @@ type
|
|||
QtObject:
|
||||
type
|
||||
Model* = ref object of QAbstractListModel
|
||||
items: seq[Item]
|
||||
delegate: io_interface.NetworksDataSource
|
||||
|
||||
proc delete(self: Model) =
|
||||
self.items = @[]
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: Model) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newModel*(): Model =
|
||||
proc newModel*(delegate: io_interface.NetworksDataSource): Model =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc `$`*(self: Model): string =
|
||||
for i in 0 ..< self.items.len:
|
||||
result &= fmt"""[{i}]:({$self.items[i]})"""
|
||||
result.delegate = delegate
|
||||
|
||||
proc countChanged(self: Model) {.signal.}
|
||||
|
||||
proc getCount(self: Model): int {.slot.} =
|
||||
self.items.len
|
||||
return self.delegate.getFlatNetworksList().len
|
||||
|
||||
QtProperty[int] count:
|
||||
read = getCount
|
||||
notify = countChanged
|
||||
|
||||
method rowCount*(self: Model, index: QModelIndex = nil): int =
|
||||
return self.items.len
|
||||
return self.delegate.getFlatNetworksList().len
|
||||
|
||||
method roleNames(self: Model): Table[int, string] =
|
||||
{
|
||||
|
@ -76,179 +72,118 @@ QtObject:
|
|||
if (not index.isValid):
|
||||
return
|
||||
|
||||
if (index.row < 0 or index.row >= self.items.len):
|
||||
if (index.row < 0 or index.row >= self.rowCount()):
|
||||
return
|
||||
|
||||
let item = self.items[index.row]
|
||||
let item = self.delegate.getFlatNetworksList()[index.row]
|
||||
let enumRole = role.ModelRole
|
||||
|
||||
case enumRole:
|
||||
of ModelRole.ChainId:
|
||||
result = newQVariant(item.getChainId())
|
||||
result = newQVariant(item.chainId)
|
||||
of ModelRole.NativeCurrencyDecimals:
|
||||
result = newQVariant(item.getNativeCurrencyDecimals())
|
||||
result = newQVariant(item.nativeCurrencyDecimals)
|
||||
of ModelRole.Layer:
|
||||
result = newQVariant(item.getLayer())
|
||||
result = newQVariant(item.layer)
|
||||
of ModelRole.ChainName:
|
||||
result = newQVariant(item.getChainName())
|
||||
result = newQVariant(item.chainName)
|
||||
of ModelRole.RpcURL:
|
||||
result = newQVariant(item.getRpcURL())
|
||||
result = newQVariant(item.rpcURL)
|
||||
of ModelRole.BlockExplorerURL:
|
||||
result = newQVariant(item.getBlockExplorerURL())
|
||||
result = newQVariant(item.blockExplorerURL)
|
||||
of ModelRole.NativeCurrencyName:
|
||||
result = newQVariant(item.getNativeCurrencyName())
|
||||
result = newQVariant(item.nativeCurrencyName)
|
||||
of ModelRole.NativeCurrencySymbol:
|
||||
result = newQVariant(item.getNativeCurrencySymbol())
|
||||
result = newQVariant(item.nativeCurrencySymbol)
|
||||
of ModelRole.IsTest:
|
||||
result = newQVariant(item.getIsTest())
|
||||
result = newQVariant(item.isTest)
|
||||
of ModelRole.IsEnabled:
|
||||
result = newQVariant(item.getIsEnabled())
|
||||
result = newQVariant(item.enabled)
|
||||
of ModelRole.IconUrl:
|
||||
result = newQVariant(item.getIconURL())
|
||||
result = newQVariant(item.iconURL)
|
||||
of ModelRole.ShortName:
|
||||
result = newQVariant(item.getShortName())
|
||||
result = newQVariant(item.shortName)
|
||||
of ModelRole.ChainColor:
|
||||
result = newQVariant(item.getChainColor())
|
||||
result = newQVariant(item.chainColor)
|
||||
of ModelRole.EnabledState:
|
||||
result = newQVariant(item.getEnabledState().int)
|
||||
result = newQVariant(item.enabledState.int)
|
||||
|
||||
proc rowData*(self: Model, index: int, column: string): string {.slot.} =
|
||||
if (index >= self.items.len):
|
||||
if (index >= self.rowCount()):
|
||||
return
|
||||
let item = self.items[index]
|
||||
let item = self.delegate.getFlatNetworksList()[index]
|
||||
case column:
|
||||
of "chainId": result = $item.getChainId()
|
||||
of "nativeCurrencyDecimals": result = $item.getNativeCurrencyDecimals()
|
||||
of "layer": result = $item.getLayer()
|
||||
of "chainName": result = $item.getChainName()
|
||||
of "rpcURL": result = $item.getRpcURL()
|
||||
of "blockExplorerURL": result = $item.getBlockExplorerURL()
|
||||
of "nativeCurrencyName": result = $item.getNativeCurrencyName()
|
||||
of "nativeCurrencySymbol": result = $item.getNativeCurrencySymbol()
|
||||
of "isTest": result = $item.getIsTest()
|
||||
of "isEnabled": result = $item.getIsEnabled()
|
||||
of "iconUrl": result = $item.getIconURL()
|
||||
of "chainColor": result = $item.getChainColor()
|
||||
of "shortName": result = $item.getShortName()
|
||||
of "enabledState": result = $item.getEnabledState().int
|
||||
of "chainId": result = $item.chainId
|
||||
of "nativeCurrencyDecimals": result = $item.nativeCurrencyDecimals
|
||||
of "layer": result = $item.layer
|
||||
of "chainName": result = $item.chainName
|
||||
of "rpcURL": result = $item.rpcURL
|
||||
of "blockExplorerURL": result = $item.blockExplorerURL
|
||||
of "nativeCurrencyName": result = $item.nativeCurrencyName
|
||||
of "nativeCurrencySymbol": result = $item.nativeCurrencySymbol
|
||||
of "isTest": result = $item.isTest
|
||||
of "isEnabled": result = $item.enabled
|
||||
of "iconUrl": result = $item.iconURL
|
||||
of "chainColor": result = $item.chainColor
|
||||
of "shortName": result = $item.shortName
|
||||
of "enabledState": result = $item.enabledState.int
|
||||
|
||||
proc setItems*(self: Model, items: seq[Item]) =
|
||||
proc refreshModel*(self: Model) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
proc getChainColor*(self: Model, chainId: int): string {.slot.} =
|
||||
for item in self.items:
|
||||
if(item.getChainId() == chainId):
|
||||
return item.getChainColor()
|
||||
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
|
||||
proc getBlockExplorerURL*(self: Model, chainId: int): string =
|
||||
for item in self.delegate.getFlatNetworksList():
|
||||
if(item.chainId == chainId):
|
||||
return item.blockExplorerURL & EXPLORER_TX_PREFIX
|
||||
return ""
|
||||
|
||||
proc getEnabledState*(self: Model, chainId: int): UxEnabledState =
|
||||
for item in self.items:
|
||||
if(item.getChainId() == chainId):
|
||||
return item.getEnabledState()
|
||||
for item in self.delegate.getFlatNetworksList():
|
||||
if(item.chainId == chainId):
|
||||
return item.enabledState
|
||||
return UxEnabledState.Disabled
|
||||
|
||||
# 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
|
||||
# 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 enable = false
|
||||
case self.getEnabledState(chainId):
|
||||
of UxEnabledState.Enabled:
|
||||
# Iterate to check for the only chainId enabled case ...
|
||||
for item in self.items:
|
||||
if item.getEnabledState() == UxEnabledState.Enabled and item.getChainId() != chainId:
|
||||
for item in filteredNetworks:
|
||||
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
|
||||
chainIds.add(chainId)
|
||||
break
|
||||
|
||||
# ... if no other chains are enabled, then it's a transition from only chainId enabled to all enabled
|
||||
if chainIds.len == 0:
|
||||
for item in self.items:
|
||||
if item.getChainId() != chainId:
|
||||
chainIds.add(item.getChainId())
|
||||
for item in filteredNetworks:
|
||||
if item.chainId != chainId:
|
||||
chainIds.add(item.chainId)
|
||||
enable = true
|
||||
of UxEnabledState.Disabled:
|
||||
chainIds.add(chainId)
|
||||
enable = true
|
||||
of UxEnabledState.AllEnabled:
|
||||
# disable all but chainId
|
||||
for item in self.items:
|
||||
if item.getChainId() != chainId:
|
||||
chainIds.add(item.getChainId())
|
||||
for item in filteredNetworks:
|
||||
if item.chainId != chainId:
|
||||
chainIds.add(item.chainId)
|
||||
|
||||
return (chainIds, enable)
|
||||
|
||||
proc getNetworkShortNames*(self: Model, preferredNetworks: string): string =
|
||||
proc getNetworkShortNames*(self: Model, preferredNetworks: string, areTestNetworksEnabled: bool): string =
|
||||
var networkString = ""
|
||||
let networks = preferredNetworks.split(":")
|
||||
for nw in networks:
|
||||
for item in self.items:
|
||||
if $item.getChainId() == nw:
|
||||
networkString = networkString & item.getShortName() & ':'
|
||||
for item in self.delegate.getFlatNetworksList():
|
||||
if $item.chainId == nw and item.isTest == areTestNetworksEnabled:
|
||||
networkString = networkString & item.shortName & ':'
|
||||
break
|
||||
return networkString
|
||||
|
||||
|
@ -256,11 +191,11 @@ QtObject:
|
|||
var networkIds = ""
|
||||
let networksNames = shortNames.split(":")
|
||||
for name in networksNames:
|
||||
for item in self.items:
|
||||
if item.getShortName() == name:
|
||||
networkIds = networkIds & $item.getChainId() & ':'
|
||||
for item in self.delegate.getFlatNetworksList():
|
||||
if item.shortName == name:
|
||||
networkIds = networkIds & $item.chainId & ':'
|
||||
break
|
||||
return networkIds
|
||||
|
||||
proc getAllNetworksChainIds*(self: Model): string =
|
||||
return self.items.map(x => x.getChainId()).join(":")
|
||||
proc getEnabledChainIds*(self: Model, areTestNetworksEnabled: bool): string =
|
||||
return self.delegate.getFlatNetworksList().filter(n => n.enabled and n.isTest == areTestNetworksEnabled).map(n => n.chainId).join(":")
|
||||
|
|
|
@ -40,7 +40,7 @@ method delete*(self: Module) =
|
|||
|
||||
method refreshNetworks*(self: Module) =
|
||||
self.view.setAreTestNetworksEnabled(self.controller.areTestNetworksEnabled())
|
||||
self.view.setItems(self.controller.getFlatNetworks())
|
||||
self.view.refreshModel()
|
||||
|
||||
method load*(self: Module) =
|
||||
self.controller.init()
|
||||
|
@ -63,5 +63,9 @@ method viewDidLoad*(self: Module) =
|
|||
method setNetworksState*(self: Module, chainIds: seq[int], enabled: bool) =
|
||||
self.controller.setNetworksState(chainIds, enabled)
|
||||
|
||||
method getNetworkLayer*(self: Module, chainId: int): string =
|
||||
return self.view.getNetworkLayer(chainId)
|
||||
# Interfaces for getting lists from the service files into the abstract models
|
||||
|
||||
method getNetworksDataSource*(self: Module): NetworksDataSource =
|
||||
return (
|
||||
getFlatNetworksList: proc(): var seq[NetworkDto] = self.controller.getFlatNetworks()
|
||||
)
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
import NimQml, sequtils, sugar, strutils
|
||||
import NimQml, sequtils, strutils
|
||||
|
||||
import app_service/service/network/[dto, types]
|
||||
import ./io_interface
|
||||
import ./model
|
||||
import ./item
|
||||
|
||||
proc networkEnabledToUxEnabledState(enabled: bool, allEnabled: bool): UxEnabledState
|
||||
proc areAllEnabled(networks: seq[NetworkDto]): bool
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
delegate: io_interface.AccessInterface
|
||||
all: Model
|
||||
enabled: Model
|
||||
layer1: Model
|
||||
layer2: Model
|
||||
flatNetworks: Model
|
||||
areTestNetworksEnabled: bool
|
||||
enabledChainIds: string
|
||||
|
@ -29,11 +20,7 @@ QtObject:
|
|||
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||
new(result, delete)
|
||||
result.delegate = delegate
|
||||
result.all = newModel()
|
||||
result.layer1 = newModel()
|
||||
result.layer2 = newModel()
|
||||
result.enabled = newModel()
|
||||
result.flatNetworks = newModel()
|
||||
result.flatNetworks = newModel(delegate.getNetworksDataSource())
|
||||
result.enabledChainIds = ""
|
||||
result.setup()
|
||||
|
||||
|
@ -50,34 +37,6 @@ QtObject:
|
|||
self.areTestNetworksEnabled = areTestNetworksEnabled
|
||||
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 getFlatNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.flatNetworks)
|
||||
|
@ -85,15 +44,6 @@ QtObject:
|
|||
read = getFlatNetworks
|
||||
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 getEnabledChainIds(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.enabledChainIds)
|
||||
|
@ -101,71 +51,24 @@ QtObject:
|
|||
read = getEnabledChainIds
|
||||
notify = enabledChainIdsChanged
|
||||
|
||||
proc setItems*(self: View, networks: seq[NetworkDto]) =
|
||||
var items: seq[Item] = @[]
|
||||
let allEnabled = areAllEnabled(networks)
|
||||
for n in networks:
|
||||
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()
|
||||
proc refreshModel*(self: View) =
|
||||
self.flatNetworks.refreshModel()
|
||||
self.enabledChainIds = self.flatNetworks.getEnabledChainIds(self.areTestNetworksEnabled)
|
||||
self.flatNetworksChanged()
|
||||
self.enabledChainIdsChanged()
|
||||
|
||||
proc load*(self: View) =
|
||||
self.delegate.viewDidLoad()
|
||||
|
||||
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)
|
||||
|
||||
proc getMainnetChainId*(self: View): int {.slot.} =
|
||||
return self.layer1.getLayer1Network(self.areTestNetworksEnabled)
|
||||
|
||||
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.} =
|
||||
return self.all.getNetworkIds(shortNames)
|
||||
return self.flatNetworks.getNetworkIds(shortNames)
|
||||
|
||||
proc getAllNetworksChainIds*(self: View): string {.slot.} =
|
||||
return self.all.getAllNetworksChainIds()
|
||||
|
||||
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)
|
||||
proc getBlockExplorerURL*(self: View, chainId: int): string {.slot.} =
|
||||
return self.flatNetworks.getBlockExplorerURL(chainId)
|
||||
|
|
|
@ -80,10 +80,10 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
|
|||
return self.walletAccountService.getWalletAccounts()
|
||||
|
||||
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] =
|
||||
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 =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
@ -130,8 +130,8 @@ proc areTestNetworksEnabled*(self: Controller): bool =
|
|||
proc getTotalCurrencyBalance*(self: Controller, address: seq[string], chainIds: seq[int]): float64 =
|
||||
return self.walletAccountService.getTotalCurrencyBalance(address, chainIds)
|
||||
|
||||
proc getNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networkService.getNetworks()
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
return self.networkService.getCurrentNetworks()
|
||||
|
||||
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
|
||||
return self.walletAccountService.getKeypairByAccountAddress(address)
|
||||
|
|
|
@ -194,7 +194,7 @@ method refreshWalletAccounts*(self: Module) =
|
|||
self.view.switchReceiveAccount(self.receiveCurrentAccountIndex)
|
||||
|
||||
proc refreshNetworks*(self: Module) =
|
||||
let networks = self.controller.getNetworks()
|
||||
let networks = self.controller.getCurrentNetworks()
|
||||
let fromNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x))
|
||||
let toNetworks = networks.map(x => self.convertNetworkDtoToNetworkItem(x))
|
||||
self.view.setNetworkItems(fromNetworks, toNetworks)
|
||||
|
|
|
@ -262,7 +262,7 @@ QtObject:
|
|||
self.items[i].isPreferred = true
|
||||
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:
|
||||
if cmpIgnoreCase(item.getShortName(), shortName) == 0:
|
||||
return item.getChainColor()
|
||||
|
|
|
@ -54,7 +54,7 @@ QtObject:
|
|||
notify = isDetailedEntryLoadingChanged
|
||||
|
||||
proc getExtraData(self: Controller, chainID: int): ExtraData =
|
||||
let network = self.networkService.getNetwork(chainID)
|
||||
let network = self.networkService.getNetworkByChainId(chainID)
|
||||
return getExtraData(network)
|
||||
|
||||
proc processGetCollectiblesDetailsResponse(self: Controller, response: JsonNode) =
|
||||
|
|
|
@ -147,7 +147,7 @@ QtObject:
|
|||
self.loadMoreItems()
|
||||
|
||||
proc getExtraData(self: Controller, chainID: int): ExtraData =
|
||||
let network = self.networkService.getNetwork(chainID)
|
||||
let network = self.networkService.getNetworkByChainId(chainID)
|
||||
return getExtraData(network)
|
||||
|
||||
proc setTempItems(self: Controller, newItems: seq[CollectiblesEntry], offset: int) =
|
||||
|
|
|
@ -470,7 +470,7 @@ QtObject:
|
|||
self.resetMessageCursor(chatArg.chatId)
|
||||
|
||||
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)
|
||||
|
||||
if message.transactionParameters.contract != "":
|
||||
|
|
|
@ -5,6 +5,12 @@ import ./types
|
|||
|
||||
export types
|
||||
|
||||
type
|
||||
UxEnabledState* {.pure.} = enum
|
||||
Enabled
|
||||
AllEnabled
|
||||
Disabled
|
||||
|
||||
type NetworkDto* = ref object
|
||||
chainId* {.serializedFieldName("chainId").}: int
|
||||
nativeCurrencyDecimals* {.serializedFieldName("nativeCurrencyDecimals").}: int
|
||||
|
@ -23,6 +29,7 @@ type NetworkDto* = ref object
|
|||
chainColor* {.serializedFieldName("chainColor").}: string
|
||||
shortName* {.serializedFieldName("shortName").}: string
|
||||
relatedChainId* {.serializedFieldName("relatedChainId").}: int
|
||||
enabledState*: UxEnabledState
|
||||
|
||||
proc `$`*(self: NetworkDto): string =
|
||||
return fmt"""Network(
|
||||
|
@ -40,7 +47,8 @@ proc `$`*(self: NetworkDto): string =
|
|||
isTest:{self.isTest}, enabled:{self.enabled},
|
||||
chainColor:{self.chainColor},
|
||||
shortName:{self.shortName},
|
||||
relatedChainId:{self.relatedChainId}
|
||||
relatedChainId:{self.relatedChainId},
|
||||
enabledState:{self.enabledState}
|
||||
)"""
|
||||
|
||||
proc hash*(self: NetworkDto): Hash =
|
||||
|
@ -56,3 +64,10 @@ proc `$`*(self: CombinedNetworkDto): string =
|
|||
test:{$self.test},
|
||||
)"""
|
||||
|
||||
proc networkEnabledToUxEnabledState*(enabled: bool, allEnabled: bool): UxEnabledState =
|
||||
return if allEnabled:
|
||||
UxEnabledState.AllEnabled
|
||||
elif enabled:
|
||||
UxEnabledState.Enabled
|
||||
else:
|
||||
UxEnabledState.Disabled
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import json, json_serialization, chronicles, atomics
|
||||
import json, json_serialization, chronicles, sugar, sequtils
|
||||
|
||||
import ../../../app/core/eventemitter
|
||||
import ../../../backend/backend as backend
|
||||
|
@ -21,12 +21,10 @@ type NetworkEndpointUpdatedArgs* = ref object of Args
|
|||
type
|
||||
Service* = ref object of RootObj
|
||||
events: EventEmitter
|
||||
networks: seq[CombinedNetworkDto]
|
||||
networksInited: bool
|
||||
dirty: Atomic[bool]
|
||||
combinedNetworks: seq[CombinedNetworkDto]
|
||||
flatNetworks: seq[NetworkDto]
|
||||
settingsService: settings_service.Service
|
||||
|
||||
|
||||
proc delete*(self: Service) =
|
||||
discard
|
||||
|
||||
|
@ -35,50 +33,38 @@ proc newService*(events: EventEmitter, settingsService: settings_service.Service
|
|||
result.events = events
|
||||
result.settingsService = settingsService
|
||||
|
||||
proc init*(self: Service) =
|
||||
discard
|
||||
proc fetchNetworks*(self: Service): seq[CombinedNetworkDto]=
|
||||
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] =
|
||||
let cacheIsDirty = not self.networksInited or self.dirty.load
|
||||
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 init*(self: Service) =
|
||||
discard self.fetchNetworks()
|
||||
|
||||
proc resetNetworks*(self: Service) =
|
||||
discard self.fetchNetworks(useCached = false)
|
||||
discard self.fetchNetworks()
|
||||
|
||||
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
|
||||
# We currently have 3 types: combined, test/mainet and flat and probably can be optimized
|
||||
# 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 getFlatNetworks*(self: Service): var seq[NetworkDto] =
|
||||
return self.flatNetworks
|
||||
|
||||
proc getNetworks*(self: Service): seq[NetworkDto] =
|
||||
let testNetworksEnabled = 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)
|
||||
# passes networks based on users choice of test/mainnet
|
||||
proc getCurrentNetworks*(self: Service): seq[NetworkDto] =
|
||||
self.flatNetworks.filter(n => n.isTest == self.settingsService.areTestNetworksEnabled())
|
||||
|
||||
proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
||||
let response = backend.addEthereumChain(backend.Network(
|
||||
|
@ -100,48 +86,34 @@ proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
|||
shortName: network.shortName,
|
||||
relatedChainID: network.relatedChainID,
|
||||
))
|
||||
self.dirty.store(true)
|
||||
return response.error == nil
|
||||
|
||||
proc deleteNetwork*(self: Service, network: NetworkDto) =
|
||||
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()
|
||||
for network in self.fetchNetworks():
|
||||
for network in networks:
|
||||
let net = if testNetworksEnabled: network.test
|
||||
else: network.prod
|
||||
if chainId == net.chainId:
|
||||
return net
|
||||
|
||||
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())
|
||||
return nil
|
||||
|
||||
proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
||||
for chainId in chainIds:
|
||||
let network = self.getNetwork(chainId)
|
||||
let network = self.getNetworkByChainId(chainId)
|
||||
|
||||
if network.enabled == enabled:
|
||||
continue
|
||||
if not network.isNil:
|
||||
if network.enabled == enabled:
|
||||
continue
|
||||
|
||||
network.enabled = enabled
|
||||
discard self.upsertNetwork(network)
|
||||
network.enabled = enabled
|
||||
discard self.upsertNetwork(network)
|
||||
discard self.fetchNetworks()
|
||||
|
||||
## 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.
|
||||
|
@ -159,7 +131,7 @@ proc getAppNetwork*(self: Service): NetworkDto =
|
|||
networkId = Sepolia
|
||||
if self.settingsService.isGoerliEnabled():
|
||||
networkId = Goerli
|
||||
let network = self.getNetwork(networkId)
|
||||
let network = self.getNetworkByChainId(networkId)
|
||||
if network.isNil:
|
||||
# we should not be here ever
|
||||
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) =
|
||||
let network = self.getNetworkByChainId(chainId)
|
||||
|
||||
if network.rpcURL != newMainRpcInput:
|
||||
network.rpcURL = newMainRpcInput
|
||||
if not network.isNil:
|
||||
if network.rpcURL != newMainRpcInput:
|
||||
network.rpcURL = newMainRpcInput
|
||||
|
||||
if network.fallbackURL != newFailoverRpcUrl:
|
||||
network.fallbackURL = newFailoverRpcUrl
|
||||
if network.fallbackURL != newFailoverRpcUrl:
|
||||
network.fallbackURL = newFailoverRpcUrl
|
||||
|
||||
if self.upsertNetwork(network):
|
||||
self.events.emit(SIGNAL_NETWORK_ENDPOINT_UPDATED, NetworkEndpointUpdatedArgs(isTest: network.isTest, networkName: network.chainName, revertedToDefault: revertToDefault))
|
||||
if self.upsertNetwork(network):
|
||||
self.events.emit(SIGNAL_NETWORK_ENDPOINT_UPDATED, NetworkEndpointUpdatedArgs(isTest: network.isTest, networkName: network.chainName, revertedToDefault: revertToDefault))
|
||||
|
|
|
@ -143,7 +143,7 @@ QtObject:
|
|||
var chaindIdsDown: seq[int] = @[]
|
||||
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:
|
||||
if chainStatusTable.hasKey($id) and chainStatusTable[$id].value != connection_status_backend.StateValue.Unknown:
|
||||
if chainStatusTable[$id].value == connection_status_backend.StateValue.Connected:
|
||||
|
|
|
@ -279,12 +279,11 @@ QtObject:
|
|||
let tokenList = Json.decode($tokensResult, TokenListDto, allowUnknownFields = true)
|
||||
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 tokenBySymbolList: Table[string, TokenBySymbolItem] = initTable[string, TokenBySymbolItem]()
|
||||
var tokenSymbols: seq[string] = @[]
|
||||
|
||||
|
||||
for s in tokenList.data:
|
||||
let newSource = SupportedSourcesItem(name: s.name, source: s.source, version: s.version, tokensCount: s.tokens.len)
|
||||
self.sourcesOfTokensList.add(newSource)
|
||||
|
|
|
@ -487,8 +487,8 @@ QtObject:
|
|||
if token != nil:
|
||||
tokenSymbol = token.symbol
|
||||
|
||||
let network = self.networkService.getNetwork(chainID)
|
||||
if network.nativeCurrencySymbol == tokenSymbol:
|
||||
let network = self.networkService.getNetworkByChainId(chainID)
|
||||
if not network.isNil and network.nativeCurrencySymbol == tokenSymbol:
|
||||
isEthTx = true
|
||||
|
||||
if(isEthTx):
|
||||
|
|
|
@ -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) =
|
||||
# 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:
|
||||
let tokenChainIds = self.tokenService.getFlatTokensList().filter(t => t.symbol == tokenSymbol and t.communityId.isEmptyOrWhitespace).map(t => t.chainID)
|
||||
chainIds = concat(chainIds, tokenChainIds)
|
||||
|
|
|
@ -761,7 +761,7 @@ proc fetchChainIdForUrl*(self: Service, url: string, isMainUrl: bool) =
|
|||
self.threadpool.start(arg)
|
||||
|
||||
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 =
|
||||
return self.currencyService.getCurrencyFormat(symbol)
|
||||
|
|
|
@ -132,7 +132,7 @@ proc getOrFetchBalanceForAddressInPreferredCurrency*(self: Service, address: str
|
|||
result.balance = 0.0
|
||||
result.fetched = false
|
||||
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.fetched = true
|
||||
|
||||
|
@ -159,7 +159,7 @@ proc checkRecentHistory*(self: Service, addresses: seq[string]) =
|
|||
if(not main_constants.WALLET_ENABLED):
|
||||
return
|
||||
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)
|
||||
except Exception as e:
|
||||
let errDescription = e.msg
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import AppLayouts.Profile.views.wallet 1.0
|
||||
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
@ -48,7 +50,10 @@ SplitView {
|
|||
}
|
||||
|
||||
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
|
||||
function toggleNetwork(chainId) {
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ SplitView {
|
|||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
currencyStore: d.currencyStore
|
||||
allNetworksModel: NetworksModel.allNetworks
|
||||
allNetworksModel: NetworksModel.flatNetworks
|
||||
networkFilters: d.networksChainsCurrentlySelected
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ SplitView {
|
|||
}
|
||||
Repeater {
|
||||
id: networksRepeater
|
||||
model: NetworksModel.allNetworks
|
||||
model: NetworksModel.flatNetworks
|
||||
delegate: CheckBox {
|
||||
property int chainID: chainId
|
||||
width: parent.width
|
||||
|
|
|
@ -72,14 +72,6 @@ SplitView {
|
|||
function formatCurrencyAmount(cryptoValue, symbol) {
|
||||
return "%L1 %2".arg(cryptoValue).arg(symbol)
|
||||
}
|
||||
|
||||
function getNetworkFullName(chainId) {
|
||||
return chainId
|
||||
}
|
||||
|
||||
function getNetworkColor(chainId) {
|
||||
return "pink"
|
||||
}
|
||||
}
|
||||
walletRootStore: QtObject {
|
||||
function getNameForAddress(address) {
|
||||
|
|
|
@ -164,7 +164,7 @@ SplitView {
|
|||
}
|
||||
Repeater {
|
||||
id: networksRepeater
|
||||
model: NetworksModel.allNetworks
|
||||
model: NetworksModel.flatNetworks
|
||||
delegate: CheckBox {
|
||||
property int chainID: chainId
|
||||
width: parent.width
|
||||
|
|
|
@ -28,8 +28,6 @@ SplitView {
|
|||
anchors.fill: parent
|
||||
anchors.margins: 50
|
||||
isAssetView: isAssetBox.checked
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
accounts: WalletAccountsModel {}
|
||||
tokensModel: MintedTokensModel {}
|
||||
referenceAssetsBySymbolModel: ListModel {
|
||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick 2.14
|
|||
import QtQuick.Controls 2.14
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Components 0.1
|
||||
|
||||
|
@ -45,10 +47,10 @@ SplitView {
|
|||
communityLogo: doodles.checked ? ModelsData.collectibles.doodles : ModelsData.collectibles.mana
|
||||
communityColor: color1.checked ? "#FFC4E9" : "#f44336"
|
||||
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
flatNetworks: SortFilterProxyModel {
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: false }
|
||||
}
|
||||
accounts: WalletAccountsModel {}
|
||||
|
||||
onMintClicked: logs.logEvent("EditOwnerTokenView::onMintClicked")
|
||||
|
|
|
@ -109,10 +109,10 @@ SplitView {
|
|||
// Models:
|
||||
tokensModel: editorModelChecked.checked ? emptyModel :
|
||||
privilegedModelChecked.checked ? privilegedTokensModel : mintedTokensModel
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
flatNetworks: SortFilterProxyModel {
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: false }
|
||||
}
|
||||
accounts: WalletAccountsModel {}
|
||||
referenceAssetsBySymbolModel: ListModel {
|
||||
ListElement {
|
||||
|
|
|
@ -5,6 +5,8 @@ import QtQuick.Layouts 1.13
|
|||
import Storybook 1.0
|
||||
import Models 1.0
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import AppLayouts.Wallet.controls 1.0
|
||||
|
||||
SplitView {
|
||||
|
@ -36,12 +38,11 @@ SplitView {
|
|||
id: networkFilter
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: 200
|
||||
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
flatNetworks: SortFilterProxyModel {
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: false; }
|
||||
}
|
||||
|
||||
multiSelection: multiSelectionCheckBox.checked
|
||||
|
||||
|
|
|
@ -38,23 +38,7 @@ SplitView {
|
|||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
allNetworks: 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; }
|
||||
}
|
||||
flatNetworks: simulatedNimModel
|
||||
|
||||
onToggleNetwork: (network) => {
|
||||
if(multiSelection) {
|
||||
|
@ -77,8 +61,7 @@ SplitView {
|
|||
NetworkSelectPopup {
|
||||
id: networkSelectPopup
|
||||
|
||||
layer1Networks: networkFilter.layer1Networks
|
||||
layer2Networks: networkFilter.layer2Networks
|
||||
flatNetworks: simulatedNimModel
|
||||
|
||||
useEnabledRole: false
|
||||
|
||||
|
@ -112,7 +95,7 @@ SplitView {
|
|||
Layout.preferredWidth: selectPopupLoader.item ? selectPopupLoader.item.width : 0
|
||||
Layout.preferredHeight: selectPopupLoader.item ? selectPopupLoader.item.height : 0
|
||||
|
||||
property var currentModel: networkFilter.layer2Networks
|
||||
property var currentModel: networkFilter.flatNetworks
|
||||
property int currentIndex: 0
|
||||
|
||||
Loader {
|
||||
|
@ -121,8 +104,7 @@ SplitView {
|
|||
active: false
|
||||
|
||||
sourceComponent: NetworkSelectPopup {
|
||||
layer1Networks: networkFilter.layer1Networks
|
||||
layer2Networks: networkFilter.layer2Networks
|
||||
flatNetworks: simulatedNimModel
|
||||
|
||||
singleSelection {
|
||||
enabled: true
|
||||
|
@ -230,7 +212,7 @@ SplitView {
|
|||
return get(index)[propName]
|
||||
}
|
||||
|
||||
sourceModel: NetworksModel.allNetworks
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: testModeCheckbox.checked; }
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@ import QtQuick 2.15
|
|||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
import Storybook 1.0
|
||||
import Models 1.0
|
||||
import AppLayouts.Wallet.popups 1.0
|
||||
|
@ -40,19 +44,61 @@ SplitView {
|
|||
"name": "My account",
|
||||
"emoji": "",
|
||||
"address": "0x1234567890123456789012345678901234567890",
|
||||
"preferredSharingChainIds": "opt:eth:"
|
||||
"preferredSharingChainIds": "10:42161:1:"
|
||||
}
|
||||
switchingAccounsEnabled: true
|
||||
changingPreferredChainsEnabled: true
|
||||
hasFloatingButtons: true
|
||||
qrImageSource: "https://upload.wikimedia.org/wikipedia/commons/4/41/QR_Code_Example.svg"
|
||||
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:"
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick 2.15
|
|||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import Storybook 1.0
|
||||
import Models 1.0
|
||||
import AppLayouts.Wallet.popups 1.0
|
||||
|
@ -32,6 +34,11 @@ SplitView {
|
|||
id: dialog
|
||||
|
||||
visible: true
|
||||
flatNetworks: SortFilterProxyModel {
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: false }
|
||||
}
|
||||
|
||||
store: QtObject {
|
||||
property var savedAddressNameExists: function() { return false }
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ SplitView {
|
|||
readonly property var flatTokensModel: FlatTokensModel {}
|
||||
readonly property var joinModel: LeftJoinModel {
|
||||
leftModel: root.flatTokensModel
|
||||
rightModel: NetworksModel.allNetworks
|
||||
rightModel: NetworksModel.flatNetworks
|
||||
|
||||
joinRole: "chainId"
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ SplitView {
|
|||
readonly property var flatTokensModel: FlatTokensModel {}
|
||||
readonly property var joinModel: LeftJoinModel {
|
||||
leftModel: root.flatTokensModel
|
||||
rightModel: NetworksModel.allNetworks
|
||||
rightModel: NetworksModel.flatNetworks
|
||||
|
||||
joinRole: "chainId"
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ SplitView {
|
|||
|
||||
assets: txStore.processedAssetsModel
|
||||
collectibles: WalletNestedCollectiblesModel {}
|
||||
networksModel: NetworksModel.allNetworks
|
||||
networksModel: NetworksModel.flatNetworks
|
||||
formatCurrentCurrencyAmount: function(balance){
|
||||
return currencyStore.formatCurrencyAmount(balance, "USD")
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import utils 1.0
|
|||
|
||||
import shared.controls 1.0
|
||||
|
||||
import Models 1.0
|
||||
|
||||
SplitView {
|
||||
id: root
|
||||
|
||||
|
@ -82,13 +84,7 @@ SplitView {
|
|||
return "%L1 %2".arg(cryptoValue).arg(symbol)
|
||||
}
|
||||
|
||||
function getNetworkFullName(chainId) {
|
||||
return chainId
|
||||
}
|
||||
|
||||
function getNetworkColor(chainId) {
|
||||
return "pink"
|
||||
}
|
||||
property var flatNetworks: NetworksModel.flatNetworks
|
||||
}
|
||||
walletRootStore: QtObject {
|
||||
function getNameForAddress(address) {
|
||||
|
|
|
@ -13,6 +13,8 @@ import shared.stores 1.0
|
|||
|
||||
import utils 1.0
|
||||
|
||||
import Models 1.0
|
||||
|
||||
SplitView {
|
||||
id: root
|
||||
|
||||
|
@ -24,20 +26,16 @@ SplitView {
|
|||
|
||||
Component.onCompleted: {
|
||||
RootStore.getFiatValue = (cryptoValue, symbol) => { return (cryptoValue * 1800).toPrecision(2) }
|
||||
RootStore.getNetworkIcon = (chainId) => { return "tiny/network/Network=Ethereum" }
|
||||
RootStore.getLatestBlockNumber = () => { return 4 }
|
||||
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.getNameForSavedWalletAddress = (address) => { return "Saved Wallet Name" }
|
||||
RootStore.getNameForAddress = (address) => { return "Address Name" }
|
||||
RootStore.getEnsForSavedWalletAddress = (address) => { return "123" }
|
||||
RootStore.getChainShortNamesForSavedWalletAddress = (address) => { return "" }
|
||||
RootStore.getGasEthValue = (gasAmount, gasPrice) => { return (gasAmount * Math.pow(10, -9)).toPrecision(5) }
|
||||
RootStore.getNetworkLayer = (chainId) => { return 1 }
|
||||
RootStore.currentCurrency = "USD"
|
||||
RootStore.flatNetworks = NetworksModel.flatNetworks
|
||||
|
||||
root.rootStoreReady = true
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import AppLayouts.Wallet.panels 1.0
|
||||
import AppLayouts.Wallet.controls 1.0
|
||||
import AppLayouts.Chat.panels 1.0
|
||||
|
@ -78,10 +80,10 @@ SplitView {
|
|||
}
|
||||
|
||||
readonly property QtObject walletStore: QtObject {
|
||||
property var allNetworks: enabledNetworks
|
||||
property var layer1Networks: NetworksModel.layer1Networks
|
||||
property var layer2Networks: NetworksModel.layer2Networks
|
||||
property var enabledNetworks: NetworksModel.enabledNetworks
|
||||
property var filteredFlatModel: SortFilterProxyModel {
|
||||
sourceModel: NetworksModel.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: false }
|
||||
}
|
||||
function toggleNetwork(chainId) {
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,26 @@ QtObject {
|
|||
readonly property int testnetNet: 5
|
||||
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) {
|
||||
if(chainId === root.ethNet)
|
||||
return "Mainnet"
|
||||
|
@ -39,157 +59,7 @@ QtObject {
|
|||
}
|
||||
}
|
||||
|
||||
readonly property var layer1Networks: 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 {
|
||||
readonly property var flatNetworks: CustomNetworkModel {
|
||||
Component.onCompleted: append([
|
||||
{
|
||||
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 {
|
||||
function updateFromNetworks(paths){
|
||||
reset()
|
||||
|
|
|
@ -16,7 +16,8 @@ ListModel {
|
|||
source: "https://gateway.ipfs.io/ipns/tokens.uniswap.org",
|
||||
version: "11.6.0",
|
||||
tokensCount: 731,
|
||||
image: ModelsData.assets.uni
|
||||
image: ModelsData.assets.uni,
|
||||
updatedAt: 1710538948
|
||||
},
|
||||
{
|
||||
key: root.status,
|
||||
|
@ -24,7 +25,8 @@ ListModel {
|
|||
source: "https://status.im/",
|
||||
version: "11.6.0",
|
||||
tokensCount: 250,
|
||||
image: ModelsData.assets.snt
|
||||
image: ModelsData.assets.snt,
|
||||
updatedAt: 1710538948
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -6,8 +6,5 @@ QtObject {
|
|||
|
||||
//
|
||||
// Silence warnings
|
||||
readonly property ListModel layer1: ListModel {}
|
||||
readonly property ListModel layer2: ListModel {}
|
||||
readonly property ListModel enabled: ListModel {}
|
||||
readonly property ListModel all: ListModel {}
|
||||
readonly property ListModel flatNetworks: ListModel {}
|
||||
}
|
|
@ -14,20 +14,16 @@ QtObject {
|
|||
property var currencyStore: CurrenciesStore {}
|
||||
property var history
|
||||
|
||||
property var getNetworkIcon
|
||||
property var getFiatValue
|
||||
property var getLatestBlockNumber
|
||||
property var hex2Dec
|
||||
property var getNetworkColor
|
||||
property var getNetworkFullName
|
||||
property var getNetworkShortName
|
||||
property var formatCurrencyAmount
|
||||
property var getNameForSavedWalletAddress
|
||||
property var getNameForAddress
|
||||
property var getEnsForSavedWalletAddress
|
||||
property var getChainShortNamesForSavedWalletAddress
|
||||
property var getGasEthValue
|
||||
property var getNetworkLayer
|
||||
property var flatNetworks
|
||||
|
||||
function copyToClipboard(text) {
|
||||
console.warn("STUB: copyToClipboard:", text)
|
||||
|
|
|
@ -24,7 +24,7 @@ QtObject {
|
|||
property ListModel model: ListModel{}
|
||||
}
|
||||
|
||||
property var allNetworksModel: NetworksModel.allNetworks
|
||||
property var flatNetworksModel: NetworksModel.flatNetworks
|
||||
property var fromNetworksModel: NetworksModel.sendFromNetworks
|
||||
property var toNetworksModel: NetworksModel.sendToNetworks
|
||||
property var selectedSenderAccount: senderAccounts.get(0)
|
||||
|
@ -182,7 +182,7 @@ QtObject {
|
|||
let listOfChains = chainIds.split(":")
|
||||
let listOfChainIds = []
|
||||
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
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ QtObject {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -11,7 +11,7 @@ QtObject {
|
|||
property string signingPhrase: walletSection.signingPhrase
|
||||
|
||||
function getEtherscanLink(chainID) {
|
||||
return networksModule.all.getBlockExplorerURL(chainID)
|
||||
return networksModule.getBlockExplorerURL(chainID)
|
||||
}
|
||||
|
||||
function switchAccountByAddress(address) {
|
||||
|
|
|
@ -491,7 +491,6 @@ QtObject {
|
|||
property var accounts: walletSectionSendInst.accounts
|
||||
property string currentCurrency: walletSection.currentCurrency
|
||||
property CurrenciesStore currencyStore: CurrenciesStore {}
|
||||
property var allNetworks: networksModule.all
|
||||
property var savedAddressesModel: walletSectionSavedAddresses.model
|
||||
|
||||
property var disabledChainIdsFromList: []
|
||||
|
|
|
@ -55,10 +55,7 @@ StackView {
|
|||
required property var referenceAssetsBySymbolModel
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
property var enabledNetworks
|
||||
property var allNetworks
|
||||
property var flatNetworks
|
||||
|
||||
signal mintCollectible(var collectibleItem)
|
||||
signal mintAsset(var assetItem)
|
||||
|
@ -226,10 +223,7 @@ StackView {
|
|||
tMasterToken.accountName: ownerTokenPage.accountName
|
||||
tMasterToken.accountAddress: ownerTokenPage.accountAddress
|
||||
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
enabledNetworks: root.enabledNetworks
|
||||
allNetworks: root.allNetworks
|
||||
flatNetworks: root.flatNetworks
|
||||
accounts: root.accounts
|
||||
|
||||
feeText: feeSubscriber.feeText
|
||||
|
@ -278,14 +272,9 @@ StackView {
|
|||
id: newTokenPage
|
||||
|
||||
readonly property int ownerTokenChainId: SQUtils.ModelUtils.get(root.tokensModel, "privilegesLevel", Constants.TokenPrivilegesLevel.Owner).chainId ?? 0
|
||||
readonly property var chainModel: NetworkModelHelpers.getLayerNetworkModelByChainId(root.layer1Networks,
|
||||
root.layer2Networks,
|
||||
ownerTokenChainId) ?? root.layer2Networks
|
||||
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)
|
||||
readonly property int chainIndex: NetworkModelHelpers.getChainIndexByChainId(root.flatNetworks, ownerTokenChainId)
|
||||
readonly property string chainName: NetworkModelHelpers.getChainName(root.flatNetworks, chainIndex)
|
||||
readonly property string chainIcon: NetworkModelHelpers.getChainIconUrl(root.flatNetworks, chainIndex)
|
||||
|
||||
property TokenObject asset: TokenObject{
|
||||
type: Constants.TokenType.ERC20
|
||||
|
@ -368,8 +357,6 @@ StackView {
|
|||
id: editView
|
||||
|
||||
viewWidth: root.viewWidth
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
accounts: root.accounts
|
||||
tokensModel: root.tokensModel
|
||||
referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel
|
||||
|
|
|
@ -354,10 +354,7 @@ StatusSectionLayout {
|
|||
// Models
|
||||
tokensModel: root.community.communityTokens
|
||||
membersModel: root.community.members
|
||||
layer1Networks: communityTokensStore.layer1Networks
|
||||
layer2Networks: communityTokensStore.layer2Networks
|
||||
enabledNetworks: communityTokensStore.enabledNetworks
|
||||
allNetworks: communityTokensStore.allNetworks
|
||||
flatNetworks: communityTokensStore.filteredFlatModel
|
||||
accounts: root.walletAccountsModel
|
||||
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@ StatusScrollView {
|
|||
property string referenceName: ""
|
||||
property string referenceSymbol: ""
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
|
||||
// Account expected roles: address, name, color, emoji, walletType
|
||||
property var accounts
|
||||
|
||||
|
|
|
@ -27,10 +27,7 @@ StatusScrollView {
|
|||
property color communityColor
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
property var enabledNetworks
|
||||
property var allNetworks
|
||||
property var flatNetworks
|
||||
|
||||
// Wallet account expected roles: address, name, color, emoji, walletType
|
||||
property var accounts
|
||||
|
@ -278,10 +275,7 @@ StatusScrollView {
|
|||
|
||||
Layout.fillWidth: true
|
||||
|
||||
allNetworks: root.allNetworks
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
enabledNetworks: root.enabledNetworks
|
||||
flatNetworks: root.flatNetworks
|
||||
multiSelection: false
|
||||
control.topPadding: 10
|
||||
control.background: Rectangle {
|
||||
|
|
|
@ -46,7 +46,7 @@ ColumnLayout {
|
|||
property var preferredSharingNetworksArray: preferredSharingNetworks.split(":").filter(Boolean)
|
||||
property string preferredSharingNetworkShortNames: walletStore.getNetworkShortNames(preferredSharingNetworks)
|
||||
onPreferredSharingNetworksChanged: {
|
||||
preferredSharingNetworksArray = preferredSharingNetworks.split(":")
|
||||
preferredSharingNetworksArray = preferredSharingNetworks.split(":").filter(Boolean)
|
||||
preferredSharingNetworkShortNames = walletStore.getNetworkShortNames(preferredSharingNetworks)
|
||||
}
|
||||
}
|
||||
|
@ -256,21 +256,7 @@ ColumnLayout {
|
|||
color: Theme.palette.transparent
|
||||
components: [
|
||||
NetworkFilter {
|
||||
layer1Networks: SortFilterProxyModel {
|
||||
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())
|
||||
}
|
||||
}
|
||||
flatNetworks: root.walletStore.networks
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: d.preferredSharingNetworksArray
|
||||
onToggleNetwork: (network) => {
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.13
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import AppLayouts.Wallet.helpers 1.0
|
||||
|
||||
import utils 1.0
|
||||
|
@ -16,10 +19,7 @@ import "../views"
|
|||
StatusComboBox {
|
||||
id: root
|
||||
|
||||
required property var allNetworks
|
||||
required property var layer1Networks
|
||||
required property var layer2Networks
|
||||
required property var enabledNetworks
|
||||
required property var flatNetworks
|
||||
property bool multiSelection: true
|
||||
property bool preferredNetworksMode: false
|
||||
property var preferredSharingNetworks: []
|
||||
|
@ -30,31 +30,31 @@ StatusComboBox {
|
|||
signal toggleNetwork(var network)
|
||||
|
||||
function setChain(chainId) {
|
||||
if(!multiSelection && !!d.currentModel && d.currentModel.count > 0) {
|
||||
d.currentModel = NetworkModelHelpers.getLayerNetworkModelByChainId(root.layer1Networks,
|
||||
root.layer2Networks,
|
||||
chainId) ?? root.layer2Networks
|
||||
d.currentIndex = NetworkModelHelpers.getChainIndexByChainId(root.layer1Networks,
|
||||
root.layer2Networks,
|
||||
chainId)
|
||||
if(!multiSelection && !!root.flatNetworks && root.flatNetworks.count > 0) {
|
||||
d.currentIndex = NetworkModelHelpers.getChainIndexByChainId(root.flatNetworks, chainId)
|
||||
if(d.currentIndex == -1)
|
||||
d.currentIndex = NetworkModelHelpers.getChainIndexForFirstLayer2Network(root.flatNetworks)
|
||||
|
||||
// Notify change:
|
||||
root.toggleNetwork(ModelUtils.get(d.currentModel, d.currentIndex))
|
||||
root.toggleNetwork(ModelUtils.get(root.flatNetworks, d.currentIndex))
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property string selectedChainName: NetworkModelHelpers.getChainName(d.currentModel, d.currentIndex)
|
||||
readonly property string selectedIconUrl: NetworkModelHelpers.getChainIconUrl(d.currentModel, d.currentIndex)
|
||||
readonly property bool allSelected: (!!root.enabledNetworks && !!root.allNetworks) ? root.enabledNetworks.count === root.allNetworks.count :
|
||||
false
|
||||
readonly property bool noneSelected: (!!root.enabledNetworks) ? root.enabledNetworks.count === 0 : false
|
||||
readonly property string selectedChainName: NetworkModelHelpers.getChainName(root.flatNetworks, d.currentIndex)
|
||||
readonly property string selectedIconUrl: NetworkModelHelpers.getChainIconUrl(root.flatNetworks, d.currentIndex)
|
||||
readonly property bool allSelected: enabledFlatNetworks.len === root.flatNetworks.count
|
||||
readonly property bool noneSelected: enabledFlatNetworks.len === 0
|
||||
|
||||
// Persist selection between selectPopupLoader reloads
|
||||
property var currentModel: layer2Networks
|
||||
property int currentIndex: 0
|
||||
|
||||
property SortFilterProxyModel enabledFlatNetworks: SortFilterProxyModel {
|
||||
sourceModel: root.flatNetworks
|
||||
filters: ValueFilter { roleName: "isEnabled"; value: true; enabled: !root.preferredNetworksMode}
|
||||
}
|
||||
}
|
||||
|
||||
onMultiSelectionChanged: root.setChain()
|
||||
|
@ -103,21 +103,20 @@ StatusComboBox {
|
|||
visible: !d.allSelected && chainRepeater.count > 0
|
||||
Repeater {
|
||||
id: chainRepeater
|
||||
model: root.multiSelection ? root.enabledNetworks : []
|
||||
model: root.preferredNetworksMode ? root.flatNetworks: root.multiSelection ? d.enabledFlatNetworks: []
|
||||
delegate: StatusRoundedImage {
|
||||
width: 24
|
||||
height: 24
|
||||
visible: image.source !== ""
|
||||
image.source: Style.svg(model.iconUrl)
|
||||
z: index + 1
|
||||
visible: root.preferredNetworksMode ? root.preferredSharingNetworks.includes(model.chainId.toString()): image.source !== ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.popup.contentItem: NetworkSelectionView {
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
flatNetworks: root.flatNetworks
|
||||
preferredSharingNetworks: root.preferredSharingNetworks
|
||||
preferredNetworksMode: root.preferredNetworksMode
|
||||
|
||||
|
@ -126,14 +125,13 @@ StatusComboBox {
|
|||
|
||||
singleSelection {
|
||||
enabled: !root.multiSelection
|
||||
currentModel: d.currentModel
|
||||
currentModel: root.flatNetworks
|
||||
currentIndex: d.currentIndex
|
||||
}
|
||||
|
||||
useEnabledRole: false
|
||||
|
||||
onToggleNetwork: (network, networkModel, index) => {
|
||||
d.currentModel = networkModel
|
||||
onToggleNetwork: (network, index) => {
|
||||
d.currentIndex = index
|
||||
root.toggleNetwork(network)
|
||||
if(singleSelection.enabled)
|
||||
|
|
|
@ -20,30 +20,33 @@ QtObject {
|
|||
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.
|
||||
function getLayerNetworkModelByChainId(layer1NetworksModel, layer2NetworksModel, chainId) {
|
||||
function getLayerNetworkModelByChainId(networksModel, chainId) {
|
||||
if(chainId) {
|
||||
if(!!layer1NetworksModel && ModelUtils.contains(layer1NetworksModel, "chainId", chainId))
|
||||
return layer1NetworksModel
|
||||
|
||||
else if(!!layer2NetworksModel && ModelUtils.contains(layer2NetworksModel, "chainId", chainId))
|
||||
return layer2NetworksModel
|
||||
if(!!networksModel && ModelUtils.contains(networksModel, "chainId", chainId))
|
||||
return networksModel
|
||||
}
|
||||
|
||||
// Default value if chainId is not part of any provided layer network model
|
||||
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.
|
||||
function getChainIndexByChainId(layer1NetworksModel, layer2NetworksModel, chainId) {
|
||||
const currentModel = getLayerNetworkModelByChainId(layer1NetworksModel, layer2NetworksModel, chainId)
|
||||
function getChainIndexByChainId(networksModel, chainId) {
|
||||
if(!!networksModel && chainId !== undefined)
|
||||
return ModelUtils.indexOf(networksModel, "chainId", chainId)
|
||||
|
||||
if(!!currentModel)
|
||||
return ModelUtils.indexOf(currentModel, "chainId", chainId)
|
||||
// Default value if no model specified
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import "../controls"
|
||||
|
@ -99,10 +102,7 @@ Item {
|
|||
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
allNetworks: walletStore.allNetworks
|
||||
layer1Networks: walletStore.layer1Networks
|
||||
layer2Networks: walletStore.layer2Networks
|
||||
enabledNetworks: walletStore.enabledNetworks
|
||||
flatNetworks: walletStore.filteredFlatModel
|
||||
|
||||
onToggleNetwork: (network) => {
|
||||
walletStore.toggleNetwork(network.chainId)
|
||||
|
|
|
@ -27,7 +27,7 @@ import ".."
|
|||
StatusModal {
|
||||
id: root
|
||||
|
||||
property var allNetworks
|
||||
property var flatNetworks
|
||||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
|
@ -187,7 +187,7 @@ StatusModal {
|
|||
d.ens = ""
|
||||
d.address = Constants.zeroAddress
|
||||
d.chainShortNames = ""
|
||||
allNetworksModelCopy.setEnabledNetworks([])
|
||||
flatNetworksModelCopy.setEnabledNetworks([])
|
||||
}
|
||||
|
||||
d.cardsModel.clear()
|
||||
|
@ -467,7 +467,7 @@ StatusModal {
|
|||
if (!prefixArrWithColumn)
|
||||
prefixArrWithColumn = []
|
||||
|
||||
allNetworksModelCopy.setEnabledNetworks(prefixArrWithColumn)
|
||||
flatNetworksModelCopy.setEnabledNetworks(prefixArrWithColumn)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,8 +496,8 @@ StatusModal {
|
|||
|
||||
function getUnknownPrefixes(prefixes) {
|
||||
let unknownPrefixes = prefixes.filter(e => {
|
||||
for (let i = 0; i < allNetworksModelCopy.count; i++) {
|
||||
if (e == allNetworksModelCopy.get(i).shortName)
|
||||
for (let i = 0; i < flatNetworksModelCopy.count; i++) {
|
||||
if (e == flatNetworksModelCopy.get(i).shortName)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -610,7 +610,7 @@ StatusModal {
|
|||
}
|
||||
|
||||
itemsModel: SortFilterProxyModel {
|
||||
sourceModel: allNetworksModelCopy
|
||||
sourceModel: flatNetworksModelCopy
|
||||
filters: ValueFilter {
|
||||
roleName: "isEnabled"
|
||||
value: true
|
||||
|
@ -674,20 +674,7 @@ StatusModal {
|
|||
NetworkSelectPopup {
|
||||
id: networkSelectPopup
|
||||
|
||||
layer1Networks: SortFilterProxyModel {
|
||||
sourceModel: allNetworksModelCopy
|
||||
filters: ValueFilter {
|
||||
roleName: "layer"
|
||||
value: 1
|
||||
}
|
||||
}
|
||||
layer2Networks: SortFilterProxyModel {
|
||||
sourceModel: allNetworksModelCopy
|
||||
filters: ValueFilter {
|
||||
roleName: "layer"
|
||||
value: 2
|
||||
}
|
||||
}
|
||||
flatNetworks: flatNetworksModelCopy
|
||||
|
||||
onToggleNetwork: (network) => {
|
||||
network.isEnabled = !network.isEnabled
|
||||
|
@ -718,9 +705,9 @@ StatusModal {
|
|||
]
|
||||
|
||||
CloneModel {
|
||||
id: allNetworksModelCopy
|
||||
id: flatNetworksModelCopy
|
||||
|
||||
sourceModel: root.allNetworks
|
||||
sourceModel: root.flatNetworks
|
||||
roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl"]
|
||||
rolesOverride: [{ role: "isEnabled", transform: (modelData) => Boolean(false) }]
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@ import QtQuick 2.15
|
|||
import QtQuick.Controls 2.15
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Popups.Dialog 0.1
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import "../stores/NetworkSelectPopup"
|
||||
|
@ -14,8 +17,7 @@ import "../views"
|
|||
StatusDialog {
|
||||
id: root
|
||||
|
||||
required property var layer1Networks
|
||||
required property var layer2Networks
|
||||
property var flatNetworks
|
||||
property var preferredSharingNetworks: []
|
||||
property bool preferredNetworksMode: false
|
||||
|
||||
|
@ -29,7 +31,7 @@ StatusDialog {
|
|||
/// 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
|
||||
/// \see SingleSelectionInfo
|
||||
signal toggleNetwork(var network, var model, int index)
|
||||
signal toggleNetwork(var network, int index)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -65,15 +67,16 @@ StatusDialog {
|
|||
|
||||
NetworkSelectionView {
|
||||
id: scrollView
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.fill: parent
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
flatNetworks: root.flatNetworks
|
||||
preferredNetworksMode: root.preferredNetworksMode
|
||||
preferredSharingNetworks: root.preferredSharingNetworks
|
||||
useEnabledRole: root.useEnabledRole
|
||||
singleSelection: d.singleSelection
|
||||
onToggleNetwork: {
|
||||
root.toggleNetwork(network, model, index)
|
||||
root.toggleNetwork(network, index)
|
||||
if(d.singleSelection.enabled)
|
||||
close()
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ StatusModal {
|
|||
property bool switchingAccounsEnabled: true
|
||||
property bool changingPreferredChainsEnabled: true
|
||||
|
||||
property string qrImageSource: RootStore.getQrCode(d.visibleAddress)
|
||||
property string qrImageSource: store.getQrCode(d.visibleAddress)
|
||||
property var getNetworkShortNames: function(chainIDsString) {
|
||||
return RootStore.getNetworkShortNames(chainIDsString)
|
||||
return store.getNetworkShortNames(chainIDsString)
|
||||
}
|
||||
|
||||
property var store: RootStore
|
||||
|
@ -131,7 +131,7 @@ StatusModal {
|
|||
}
|
||||
|
||||
onOpened: {
|
||||
RootStore.addressWasShown(root.selectedAccount.address)
|
||||
store.addressWasShown(root.selectedAccount.address)
|
||||
}
|
||||
|
||||
QtObject {
|
||||
|
@ -145,8 +145,6 @@ StatusModal {
|
|||
|
||||
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 var networkProxies: [layer1NetworksClone, layer2NetworksClone]
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -260,16 +258,13 @@ StatusModal {
|
|||
spacing: 5
|
||||
|
||||
Repeater {
|
||||
model: d.networkProxies.length
|
||||
delegate: Repeater {
|
||||
model: d.networkProxies[index]
|
||||
delegate: StatusNetworkListItemTag {
|
||||
enabled: false
|
||||
button.visible: false
|
||||
title: model.shortName
|
||||
asset.name: Style.svg("tiny/" + model.iconUrl)
|
||||
visible: d.preferredChainIdsArray.includes(model.chainId.toString())
|
||||
}
|
||||
model: root.store.filteredFlatModel
|
||||
delegate: StatusNetworkListItemTag {
|
||||
enabled: false
|
||||
button.visible: false
|
||||
title: model.shortName
|
||||
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
|
||||
|
||||
layer1Networks: layer1NetworksClone
|
||||
layer2Networks: layer2NetworksClone
|
||||
flatNetworks: root.store.filteredFlatModel
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: d.preferredChainIdsArray
|
||||
|
||||
|
@ -304,33 +298,13 @@ StatusModal {
|
|||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
onToggleNetwork: (network, networkModel, index) => {
|
||||
d.preferredChainIdsArray = RootStore.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network)
|
||||
onToggleNetwork: (network, index) => {
|
||||
d.preferredChainIdsArray = store.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network)
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
QtObject {
|
||||
property bool enabled: false
|
||||
property var currentModel: root.layer2Networks
|
||||
property var currentModel
|
||||
property int currentIndex: 0
|
||||
}
|
||||
|
|
|
@ -139,12 +139,14 @@ QtObject {
|
|||
return d.chainColors[chainShortName]
|
||||
}
|
||||
|
||||
property var layer1Networks: networksModule.layer1
|
||||
property var layer2Networks: networksModule.layer2
|
||||
property var enabledNetworks: networksModule.enabled
|
||||
property var allNetworks: networksModule.all
|
||||
onAllNetworksChanged: {
|
||||
d.initChainColors(allNetworks)
|
||||
property var flatNetworks: networksModule.flatNetworks
|
||||
property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
||||
sourceModel: root.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled }
|
||||
}
|
||||
|
||||
onFlatNetworksChanged: {
|
||||
d.initChainColors(flatNetworks)
|
||||
}
|
||||
|
||||
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
|
||||
|
@ -440,7 +442,12 @@ QtObject {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -462,7 +469,7 @@ QtObject {
|
|||
|
||||
function processPreferredSharingNetworkToggle(preferredSharingNetworks, toggledNetwork) {
|
||||
let prefChains = preferredSharingNetworks
|
||||
if(prefChains.length === allNetworks.count) {
|
||||
if(prefChains.length === root.filteredFlatModel.count) {
|
||||
prefChains = [toggledNetwork.chainId.toString()]
|
||||
}
|
||||
else if(!prefChains.includes(toggledNetwork.chainId.toString())) {
|
||||
|
@ -470,7 +477,7 @@ QtObject {
|
|||
}
|
||||
else {
|
||||
if(prefChains.length === 1) {
|
||||
prefChains = getAllNetworksChainIds().split(":")
|
||||
prefChains = getAllNetworksChainIds()
|
||||
}
|
||||
else {
|
||||
for(var i = 0; i < prefChains.length;i++) {
|
||||
|
|
|
@ -11,79 +11,51 @@ import utils 1.0
|
|||
import "../stores/NetworkSelectPopup"
|
||||
import "../controls"
|
||||
|
||||
StatusScrollView {
|
||||
StatusListView {
|
||||
id: root
|
||||
|
||||
required property var layer1Networks
|
||||
required property var layer2Networks
|
||||
required property var flatNetworks
|
||||
property bool useEnabledRole: true
|
||||
property SingleSelectionInfo singleSelection: SingleSelectionInfo {}
|
||||
property var preferredSharingNetworks: []
|
||||
property bool preferredNetworksMode: false
|
||||
|
||||
signal toggleNetwork(var network, var model, int index)
|
||||
signal toggleNetwork(var network, int index)
|
||||
|
||||
contentWidth: availableWidth
|
||||
padding: 0
|
||||
model: root.flatNetworks
|
||||
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
|
||||
Column {
|
||||
id: content
|
||||
|
||||
width: root.availableWidth
|
||||
spacing: 4
|
||||
|
||||
Repeater {
|
||||
id: chainRepeater1
|
||||
delegate: NetworkSelectItemDelegate {
|
||||
implicitHeight: 48
|
||||
implicitWidth: root.width
|
||||
radioButtonGroup: radioBtnGroup
|
||||
networkModel: root.model
|
||||
useEnabledRole: root.useEnabledRole
|
||||
singleSelection: root.singleSelection
|
||||
onToggleNetwork: root.toggleNetwork(network, index)
|
||||
preferredNetworksMode: root.preferredNetworksMode
|
||||
preferredSharingNetworks: root.preferredSharingNetworks
|
||||
allChecked: root.preferredSharingNetworks.length === root.count
|
||||
}
|
||||
|
||||
section {
|
||||
property: "layer"
|
||||
delegate: Loader {
|
||||
required property int section
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
sourceComponent: section === 2 ? layer2text: null
|
||||
|
||||
objectName: "networkSelectPopupChainRepeaterLayer1"
|
||||
model: root.layer1Networks
|
||||
|
||||
delegate: NetworkSelectItemDelegate {
|
||||
implicitHeight: 48
|
||||
implicitWidth: root.width
|
||||
radioButtonGroup: radioBtnGroup
|
||||
networkModel: chainRepeater1.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
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
Component {
|
||||
id: layer2text
|
||||
StatusBaseText {
|
||||
width: parent.width
|
||||
font.pixelSize: Style.current.primaryTextFontSize
|
||||
color: Theme.palette.baseColor1
|
||||
text: qsTr("Layer 2")
|
||||
height: 40
|
||||
leftPadding: 16
|
||||
topPadding: 10
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ RightTabBaseView {
|
|||
|
||||
visible: (stack.currentIndex === 2)
|
||||
|
||||
allNetworksModel: RootStore.allNetworks
|
||||
allNetworksModel: RootStore.filteredFlatModel
|
||||
address: RootStore.overview.mixedcaseAddress
|
||||
showAllAccounts: RootStore.showAllAccounts
|
||||
currencyStore: RootStore.currencyStore
|
||||
|
|
|
@ -7,6 +7,7 @@ import QtGraphicalEffects 1.15
|
|||
import StatusQ.Components 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
import StatusQ.Controls 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 string networkShortName: d.isTransactionValid ? RootStore.getNetworkShortName(transaction.chainId) : ""
|
||||
readonly property string networkIcon: isTransactionValid ? RootStore.getNetworkIcon(transaction.chainId) : "network/Network=Custom"
|
||||
readonly property string networkShortName: d.isTransactionValid ? ModelUtils.getByKey(RootStore.flatNetworks, "chainId", transaction.chainId, "shortName") : ""
|
||||
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 blockNumberIn: isDetailsValid ? details.blockNumberIn : 0
|
||||
readonly property int blockNumberOut: isDetailsValid ? details.blockNumberOut : 0
|
||||
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 inSymbol: isTransactionValid ? transaction.inSymbol : ""
|
||||
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
|
||||
error: transactionHeader.transactionStatus === Constants.TransactionStatus.Failed
|
||||
pending: transactionHeader.transactionStatus === Constants.TransactionStatus.Pending
|
||||
outNetworkLayer: d.isTransactionValid ? Number(RootStore.getNetworkLayer(transactionHeader.isMultiTransaction ? d.transaction.chainIdOut : d.transaction.chainId)) : 0
|
||||
inNetworkLayer: d.isTransactionValid && transactionHeader.isMultiTransaction && d.isBridge ? Number(RootStore.getNetworkLayer(d.transaction.chainIdIn)) : 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 ?
|
||||
ModelUtils.getByKey(RootStore.flatNetworks, "chainId", d.transaction.chainIdIn, "layer") : 0
|
||||
outNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0
|
||||
inNetworkTimestamp: d.isTransactionValid ? d.transaction.timestamp : 0
|
||||
outChainName: transactionHeader.isMultiTransaction ? transactionHeader.networkNameOut : transactionHeader.networkName
|
||||
|
@ -260,7 +262,7 @@ Item {
|
|||
case Constants.TransactionType.Swap:
|
||||
return Constants.tokenIcon(d.outSymbol)
|
||||
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:
|
||||
return ""
|
||||
}
|
||||
|
@ -287,7 +289,7 @@ Item {
|
|||
case Constants.TransactionType.Swap:
|
||||
return Constants.tokenIcon(d.inSymbol)
|
||||
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:
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ ListModel {
|
|||
for (let i = 0; i < model.count; i++) {
|
||||
const clonedItem = new Object()
|
||||
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) {
|
||||
clonedItem[newProp.role] = newProp.transform(clonedItem)
|
||||
|
|
|
@ -161,10 +161,10 @@ QtObject {
|
|||
readonly property bool showBrowserSelector: localAccountSensitiveSettings.showBrowserSelector
|
||||
readonly property bool openLinksInStatus: false
|
||||
|
||||
property var allNetworks: networksModule.all
|
||||
property var flatNetworks: networksModule.flatNetworks
|
||||
|
||||
function getEtherscanLink(chainID) {
|
||||
return allNetworks.getBlockExplorerURL(chainID)
|
||||
return networksModule.getBlockExplorerURL(chainID)
|
||||
}
|
||||
|
||||
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityTags,
|
||||
|
|
|
@ -1809,7 +1809,7 @@ Item {
|
|||
}
|
||||
|
||||
sourceComponent: WalletPopups.AddEditSavedAddressPopup {
|
||||
allNetworks: RootStore.allNetworks
|
||||
flatNetworks: WalletStore.RootStore.filteredFlatModel
|
||||
|
||||
onClosed: {
|
||||
addEditSavedAddress.close()
|
||||
|
|
|
@ -6,6 +6,7 @@ import StatusQ.Components 0.1
|
|||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core.Utils 0.1 as SQUtils
|
||||
|
||||
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 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 string networkColor: isModelDataValid ? rootStore.getNetworkColor(modelData.chainId) : ""
|
||||
readonly property string networkName: isModelDataValid ? rootStore.getNetworkFullName(modelData.chainId) : ""
|
||||
readonly property string networkNameIn: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdIn) : ""
|
||||
readonly property string networkNameOut: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdOut) : ""
|
||||
readonly property string networkColor: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainColor") : ""
|
||||
readonly property string networkName: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainName") : ""
|
||||
readonly property string networkNameIn: isMultiTransaction ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "chainName") : ""
|
||||
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 addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : ""
|
||||
readonly property bool isNFT: isModelDataValid && modelData.isNFT
|
||||
|
@ -246,7 +247,7 @@ StatusListItem {
|
|||
}
|
||||
|
||||
// PROGRESS
|
||||
const networkLayer = rootStore.getNetworkLayer(modelData.chainId)
|
||||
const networkLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "layer")
|
||||
|
||||
const isBridge = type === Constants.TransactionType.Bridge
|
||||
switch(transactionStatus) {
|
||||
|
@ -272,7 +273,7 @@ StatusListItem {
|
|||
details += qsTr("Confirmed on %1").arg(root.networkName) + endl
|
||||
details += LocaleUtils.formatDateTime(confirmationTimeStamp * 1000, Locale.LongFormat) + endl2
|
||||
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)
|
||||
details += qsTr("Signed on %1").arg(root.networkNameIn) + endl + timestampString + endl2
|
||||
details += qsTr("Confirmed on %1").arg(root.networkNameIn) + endl
|
||||
|
@ -293,7 +294,7 @@ StatusListItem {
|
|||
details += qsTr("Finalised on %1").arg(root.networkName) + endl
|
||||
details += LocaleUtils.formatDateTime(finalisationTimeStamp * 1000, Locale.LongFormat) + endl2
|
||||
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 finalisationTimeStampIn = WalletUtils.calculateFinalisationTimestamp(networkInLayer, modelData.timestamp)
|
||||
const epochIn = Math.abs(walletRootStore.getEstimatedLatestBlockNumber(modelData.chainIdIn) - detailsObj.blockNumberIn)
|
||||
|
|
|
@ -268,7 +268,7 @@ StatusDialog {
|
|||
selectedSenderAccount: store.selectedSenderAccount.address
|
||||
assetsModel: popup.store.processedAssetsModel
|
||||
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
||||
networksModel: popup.store.allNetworksModel
|
||||
networksModel: popup.store.flatNetworksModel
|
||||
currentCurrencySymbol: d.currencyStore.currentCurrencySymbol
|
||||
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) ||
|
||||
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown)
|
||||
|
@ -400,7 +400,7 @@ StatusDialog {
|
|||
selectedSenderAccount: store.selectedSenderAccount.address
|
||||
assets: popup.store.processedAssetsModel
|
||||
collectibles: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
|
||||
networksModel: popup.store.allNetworksModel
|
||||
networksModel: popup.store.flatNetworksModel
|
||||
onlyAssets: holdingSelector.onlyAssets
|
||||
onTokenSelected: {
|
||||
d.setSelectedHoldingId(symbol, holdingType)
|
||||
|
|
|
@ -88,7 +88,7 @@ Item {
|
|||
errorMode: root.errorMode
|
||||
errorType: root.errorType
|
||||
toNetworksList: root.toNetworksList
|
||||
selectedSymbol: root.selectedAsset.symbol
|
||||
selectedSymbol: !!root.selectedAsset ? root.selectedAsset.symbol: ""
|
||||
weiToEth: function(wei) {
|
||||
if(!!selectedAsset && root.selectedAsset !== undefined)
|
||||
return parseFloat(store.getWei2Eth(wei, root.selectedAsset.decimals))
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import QtQuick 2.15
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
QtObject {
|
||||
|
@ -7,10 +9,11 @@ QtObject {
|
|||
property var communityTokensModuleInst: communityTokensModule ?? null
|
||||
|
||||
// Network selection properties:
|
||||
property var layer1Networks: networksModule.layer1
|
||||
property var layer2Networks: networksModule.layer2
|
||||
property var enabledNetworks: networksModule.enabled
|
||||
property var allNetworks: networksModule.all
|
||||
property var flatNetworks: networksModule.flatNetworks
|
||||
property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
||||
sourceModel: root.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: networksModule.areTestNetworksEnabled }
|
||||
}
|
||||
|
||||
// set by asyncGetOwnerTokenDetails
|
||||
readonly property var ownerTokenDetails: {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import QtQuick 2.13
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
|
@ -15,8 +17,13 @@ QtObject {
|
|||
readonly property bool balanceCache: walletSectionAssets.hasBalanceCache
|
||||
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 bool atleastOneBlockchainNetworkAvailable: blockchainNetworksDown.length < networksModule.all.count
|
||||
readonly property bool atleastOneBlockchainNetworkAvailable: blockchainNetworksDown.length < __filteredflatNetworks.count
|
||||
|
||||
readonly property bool sendBuyBridgeEnabled: localAppSettings.testEnvironment || (isOnline &&
|
||||
(!networkConnectionModule.blockchainNetworkConnection.completelyDown && atleastOneBlockchainNetworkAvailable) &&
|
||||
|
@ -52,9 +59,10 @@ QtObject {
|
|||
readonly property bool noTokenBalanceAvailable: notOnlineWithNoCache || noBlockchainConnectionAndNoCache
|
||||
|
||||
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 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) {
|
||||
if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) {
|
||||
|
@ -88,7 +96,7 @@ QtObject {
|
|||
let jointChainIdString = ""
|
||||
for (const chain of chainIdsDown) {
|
||||
jointChainIdString = (!!jointChainIdString) ? jointChainIdString + " & " : jointChainIdString
|
||||
jointChainIdString += networksModule.all.getNetworkFullName(parseInt(chain))
|
||||
jointChainIdString += ModelUtils.getByKey(networksModule.flatNetworks, "chainId", parseInt(chain), "chainName")
|
||||
}
|
||||
return jointChainIdString
|
||||
}
|
||||
|
|
|
@ -30,41 +30,12 @@ QtObject {
|
|||
property bool isNonArchivalNode: Global.appIsReady && walletSectionInst.isNonArchivalNode
|
||||
|
||||
property var marketValueStore: TokenMarketValuesStore{}
|
||||
property var allNetworks: networksModule.all
|
||||
|
||||
function resetActivityData() {
|
||||
walletSectionInst.activityController.resetActivityData()
|
||||
}
|
||||
|
||||
// TODO remove all these by linking chainId for networks and activity using LeftJoinModel
|
||||
// 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)
|
||||
}
|
||||
property var flatNetworks: networksModule.flatNetworks
|
||||
|
||||
function hex2Dec(value) {
|
||||
return globalUtils.hex2Dec(value)
|
||||
|
|
|
@ -23,7 +23,7 @@ QtObject {
|
|||
|
||||
property var fromNetworksModel: walletSectionSendInst.fromNetworksModel
|
||||
property var toNetworksModel: walletSectionSendInst.toNetworksModel
|
||||
property var allNetworksModel: networksModule.all
|
||||
property var flatNetworksModel: networksModule.flatNetworks
|
||||
property var senderAccounts: walletSectionSendInst.senderAccounts
|
||||
property var selectedSenderAccount: walletSectionSendInst.selectedSenderAccount
|
||||
property var accounts: walletSectionSendInst.accounts
|
||||
|
@ -55,7 +55,7 @@ QtObject {
|
|||
}
|
||||
|
||||
function getEtherscanLink(chainID) {
|
||||
return networksModule.all.getBlockExplorerURL(chainID)
|
||||
return networksModule.getBlockExplorerURL(chainID)
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
|
|
Loading…
Reference in New Issue