fix(@desktop/wallet): Remove profile section's networks submodule and udpate logic for combined networks
This commit is contained in:
parent
d568ceb444
commit
c710f0e809
|
@ -46,7 +46,7 @@ proc getChainIds*(self: Controller): seq[int] =
|
|||
return self.networkService.getCurrentNetworks().map(n => n.chainId)
|
||||
|
||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.isEnabled).map(n => n.chainId)
|
||||
|
||||
proc getCurrentCurrency*(self: Controller): string =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
|
|
@ -6,6 +6,7 @@ import ../../../../../app_service/service/settings/service as settings_service
|
|||
import ../../../../../app_service/service/provider/service as provider_service
|
||||
import ../../../../../app_service/service/wallet_account/service
|
||||
import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app_service/service/network/network_item
|
||||
|
||||
const UNIQUE_BROWSER_SECTION_TRANSACTION_MODULE_IDENTIFIER* = "BrowserSection-TransactionModule"
|
||||
|
||||
|
@ -34,7 +35,7 @@ proc newController*(
|
|||
proc delete*(self: Controller) =
|
||||
discard
|
||||
|
||||
proc getAppNetwork*(self: Controller): NetworkDto =
|
||||
proc getAppNetwork*(self: Controller): NetworkItem =
|
||||
return self.networkService.getAppNetwork()
|
||||
|
||||
proc init*(self: Controller) =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ../../../../../app_service/service/network/service
|
||||
import app_service/service/network/network_item
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
|
@ -33,7 +33,7 @@ method onPostMessage*(self: AccessInterface, payloadMethod: string, result: stri
|
|||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateNetwork*(self: AccessInterface, network: NetworkDto) {.base.} =
|
||||
method updateNetwork*(self: AccessInterface, network: NetworkItem) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method authenticateToPostMessage*(self: AccessInterface, payloadMethod: string, requestType: string, message: string) {.base.} =
|
||||
|
|
|
@ -6,10 +6,11 @@ import std/json
|
|||
import ../../../../core/eventemitter
|
||||
|
||||
import ../io_interface as delegate_interface
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../app_service/service/provider/service as provider_service
|
||||
import ../../../../global/global_singleton
|
||||
import app_service/service/settings/service as settings_service
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/provider/service as provider_service
|
||||
import app_service/service/network/network_item
|
||||
import app/global/global_singleton
|
||||
export io_interface
|
||||
|
||||
# Shouldn't be public ever, use only within this module.
|
||||
|
@ -77,7 +78,7 @@ method onPostMessage*(self: Module, payloadMethod: string, result: string, chain
|
|||
method ensResourceURL*(self: Module, ens: string, url: string): (string, string, string, string, bool) =
|
||||
return self.controller.ensResourceURL(ens, url)
|
||||
|
||||
method updateNetwork*(self: Module, network: NetworkDto) =
|
||||
method updateNetwork*(self: Module, network: NetworkItem) =
|
||||
self.view.chainId = network.chainId
|
||||
self.view.chainName = network.chainName
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import app_service/service/wallet_account/service as wallet_account_service
|
|||
import app_service/service/keycard/service as keycard_service
|
||||
import app_service/common/types
|
||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app_service/service/network/network_item
|
||||
|
||||
const UNIQUE_COMMUNITIES_MODULE_AUTH_IDENTIFIER* = "CommunitiesModule-Authentication"
|
||||
const UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER* = "CommunitiesModule-Signing"
|
||||
|
@ -372,7 +373,7 @@ proc getCommunityTokens*(self: Controller, communityId: string): seq[CommunityTo
|
|||
proc getAllCommunityTokens*(self: Controller): seq[CommunityTokenDto] =
|
||||
self.communityTokensService.getAllCommunityTokens()
|
||||
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkItem =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getTokenBySymbolList*(self: Controller): seq[TokenBySymbolItem] =
|
||||
|
@ -480,7 +481,7 @@ proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataTo
|
|||
proc removeCommunityChat*(self: Controller, communityId: string, channelId: string) =
|
||||
self.communityService.deleteCommunityChat(communityId, channelId)
|
||||
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkItem] =
|
||||
return self.networksService.getCurrentNetworks()
|
||||
|
||||
proc promoteSelfToControlNode*(self: Controller, communityId: string) =
|
||||
|
|
|
@ -5,6 +5,7 @@ import app_service/service/community_tokens/service as community_tokens_service
|
|||
import app_service/service/transaction/service as transaction_service
|
||||
import app_service/service/network/service as networks_service
|
||||
import app_service/service/community/service as community_service
|
||||
import app_service/service/network/network_item
|
||||
import app_service/common/types
|
||||
import app/core/signals/types
|
||||
import app/core/eventemitter
|
||||
|
@ -159,7 +160,7 @@ 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 getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkItem =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getOwnerToken*(self: Controller, communityId: string): CommunityTokenDto =
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import stew/shims/strformat, sequtils, stint
|
||||
import ../../../../../../app_service/service/community_tokens/dto/community_token
|
||||
import ../../../../../../app_service/service/community_tokens/community_collectible_owner
|
||||
import ../../../../../../app_service/service/network/dto
|
||||
import ../../../../../../app_service/common/types
|
||||
import app_service/service/community_tokens/dto/community_token
|
||||
import app_service/service/community_tokens/community_collectible_owner
|
||||
import app_service/service/network/network_item
|
||||
import app_service/common/types
|
||||
|
||||
import token_owners_model
|
||||
import token_owners_item
|
||||
|
@ -23,7 +23,7 @@ type
|
|||
|
||||
proc initTokenItem*(
|
||||
tokenDto: CommunityTokenDto,
|
||||
network: NetworkDto,
|
||||
network: NetworkItem,
|
||||
tokenOwners: seq[CommunityCollectibleOwner],
|
||||
accountName: string,
|
||||
burnState: ContractTransactionStatus,
|
||||
|
|
|
@ -22,6 +22,7 @@ import app_service/service/token/service as token_service
|
|||
import app_service/service/network/service as networks_service
|
||||
import app_service/service/visual_identity/service as procs_from_visual_identity_service
|
||||
import app_service/service/shared_urls/service as urls_service
|
||||
import app_service/service/network/network_item
|
||||
|
||||
import app_service/service/community_tokens/community_collectible_owner
|
||||
|
||||
|
@ -573,10 +574,10 @@ proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string
|
|||
proc getRemoteDestructedAmount*(self: Controller, chainId: int, contractAddress: string): Uint256 =
|
||||
return self.communityTokensService.getRemoteDestructedAmount(chainId, contractAddress)
|
||||
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkDto =
|
||||
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkItem =
|
||||
self.networksService.getNetworkByChainId(chainId)
|
||||
|
||||
proc getAppNetwork*(self:Controller): NetworkDto =
|
||||
proc getAppNetwork*(self:Controller): NetworkItem =
|
||||
self.networksService.getAppNetwork()
|
||||
|
||||
proc slowdownArchivesImport*(self:Controller) =
|
||||
|
|
|
@ -15,7 +15,7 @@ import app_service/service/community_tokens/service as community_tokens_service
|
|||
import app_service/service/community_tokens/community_collectible_owner
|
||||
import app_service/service/shared_urls/service as urls_service
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/network/dto as network_dto
|
||||
import app_service/service/network/network_item
|
||||
from app_service/common/types import StatusType, ContractTransactionStatus, MembershipRequestState, Shard
|
||||
|
||||
import app/global/app_signals
|
||||
|
@ -44,7 +44,7 @@ method load*(
|
|||
{.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getAppNetwork*(self: AccessInterface): NetworkDto {.base.} =
|
||||
method getAppNetwork*(self: AccessInterface): NetworkItem {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onAppNetworkChanged*(self: AccessInterface) {.base.} =
|
||||
|
|
|
@ -69,6 +69,7 @@ import ../../../app_service/service/visual_identity/service as procs_from_visual
|
|||
import ../../../app_service/common/types
|
||||
import ../../../app_service/common/social_links
|
||||
import ../../../app_service/common/utils as common_utils
|
||||
import app_service/service/network/network_item
|
||||
|
||||
import ../../core/notifications/details
|
||||
import ../../core/eventemitter
|
||||
|
@ -259,7 +260,7 @@ method delete*[T](self: Module[T]) =
|
|||
self.view.delete
|
||||
self.viewVariant.delete
|
||||
|
||||
method getAppNetwork*[T](self: Module[T]): NetworkDto =
|
||||
method getAppNetwork*[T](self: Module[T]): NetworkItem =
|
||||
return self.controller.getAppNetwork()
|
||||
|
||||
method onAppNetworkChanged*[T](self: Module[T]) =
|
||||
|
|
|
@ -11,6 +11,7 @@ import app_service/service/token/service as token_service
|
|||
import app_service/service/keycard/service as keycard_service
|
||||
from app_service/service/transaction/dto import PendingTransactionTypeDto
|
||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app_service/service/network/network_item
|
||||
|
||||
logScope:
|
||||
topics = "profile-section-ens-usernames-module-controller"
|
||||
|
@ -72,7 +73,7 @@ proc init*(self: Controller) =
|
|||
return
|
||||
self.delegate.onKeypairAuthenticated(args.password, args.pin)
|
||||
|
||||
proc getAppNetwork*(self: Controller): NetworkDto =
|
||||
proc getAppNetwork*(self: Controller): NetworkItem =
|
||||
return self.networkService.getAppNetwork()
|
||||
|
||||
proc checkEnsUsernameAvailability*(self: Controller, desiredEnsUsername: string, statusDomain: bool) =
|
||||
|
|
|
@ -104,9 +104,6 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
|
|||
proc getChainIds*(self: Controller): seq[int] =
|
||||
self.networkService.getCurrentNetworks().map(n => n.chainId)
|
||||
|
||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||
self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
|
||||
proc setSocialLinks*(self: Controller, links: SocialLinks) =
|
||||
self.settingsService.setSocialLinks(links)
|
||||
|
||||
|
|
|
@ -81,6 +81,18 @@ QtObject:
|
|||
break
|
||||
i.inc
|
||||
|
||||
proc onPreferredSharingChainsUpdated*(self: Model, address, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
var i = 0
|
||||
for item in self.items.mitems:
|
||||
if address == item.address:
|
||||
item.prodPreferredChainIds = prodPreferredChainIds
|
||||
item.testPreferredChainIds = testPreferredChainIds
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
defer: index.delete
|
||||
self.dataChanged(index, index, @[ModelRole.PreferredSharingChainIds.int])
|
||||
break
|
||||
i.inc
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
if (not index.isValid):
|
||||
return
|
||||
|
|
|
@ -94,6 +94,7 @@ QtObject:
|
|||
self.refreshSelectedAccount()
|
||||
|
||||
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
self.accounts.onPreferredSharingChainsUpdated(address, prodPreferredChainIds, testPreferredChainIds)
|
||||
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
|
||||
self.refreshSelectedAccount()
|
||||
|
||||
|
|
|
@ -31,12 +31,6 @@ method accountsModuleDidLoad*(self: AccessInterface) {.base.} =
|
|||
method getAccountsModule*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method networksModuleDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getNetworksModule*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCollectiblesModel*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import ./controller, ./view
|
|||
import ../io_interface as delegate_interface
|
||||
|
||||
import ./accounts/module as accounts_module
|
||||
import ./networks/module as networks_module
|
||||
|
||||
import app/global/global_singleton
|
||||
import app/core/eventemitter
|
||||
|
@ -36,7 +35,6 @@ type
|
|||
devicesService: devices_service.Service
|
||||
nodeService: node_service.Service
|
||||
accountsModule: accounts_module.AccessInterface
|
||||
networksModule: networks_module.AccessInterface
|
||||
keypairImportModule: keypair_import_module.AccessInterface
|
||||
|
||||
proc newModule*(
|
||||
|
@ -60,21 +58,18 @@ proc newModule*(
|
|||
result.walletAccountService = walletAccountService
|
||||
result.devicesService = devicesService
|
||||
result.accountsModule = accounts_module.newModule(result, events, walletAccountService, networkService)
|
||||
result.networksModule = networks_module.newModule(result, events, networkService, walletAccountService, settingsService)
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.controller.delete
|
||||
self.view.delete
|
||||
self.viewVariant.delete
|
||||
self.accountsModule.delete
|
||||
self.networksModule.delete
|
||||
if not self.keypairImportModule.isNil:
|
||||
self.keypairImportModule.delete
|
||||
|
||||
method load*(self: Module) =
|
||||
self.controller.init()
|
||||
self.accountsModule.load()
|
||||
self.networksModule.load()
|
||||
|
||||
method isLoaded*(self: Module): bool =
|
||||
return self.moduleLoaded
|
||||
|
@ -89,9 +84,6 @@ proc checkIfModuleDidLoad(self: Module) =
|
|||
if(not self.accountsModule.isLoaded()):
|
||||
return
|
||||
|
||||
if(not self.networksModule.isLoaded()):
|
||||
return
|
||||
|
||||
self.moduleLoaded = true
|
||||
self.delegate.walletModuleDidLoad()
|
||||
|
||||
|
@ -104,12 +96,6 @@ method accountsModuleDidLoad*(self: Module) =
|
|||
method getAccountsModule*(self: Module): QVariant =
|
||||
return self.accountsModule.getModuleAsVariant()
|
||||
|
||||
method networksModuleDidLoad*(self: Module) =
|
||||
self.checkIfModuleDidLoad()
|
||||
|
||||
method getNetworksModule*(self: Module): QVariant =
|
||||
return self.networksModule.getModuleAsVariant()
|
||||
|
||||
method destroyKeypairImportPopup*(self: Module) =
|
||||
if self.keypairImportModule.isNil:
|
||||
return
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import stew/shims/strformat
|
||||
|
||||
import ./item
|
||||
|
||||
type
|
||||
CombinedItem* = object
|
||||
prod: Item
|
||||
test: Item
|
||||
layer: int
|
||||
|
||||
proc initCombinedItem*(
|
||||
prod: Item,
|
||||
test: Item,
|
||||
layer: int
|
||||
): CombinedItem =
|
||||
result.prod = prod
|
||||
result.test = test
|
||||
result.layer = layer
|
||||
|
||||
proc `$`*(self: CombinedItem): string =
|
||||
result = fmt"""CombinedItem(
|
||||
prod: {self.prod},
|
||||
test: {self.test},
|
||||
layer: {self.layer},
|
||||
]"""
|
||||
|
||||
proc getProd*(self: CombinedItem): Item =
|
||||
return self.prod
|
||||
|
||||
proc getTest*(self: CombinedItem): Item =
|
||||
return self.test
|
||||
|
||||
proc getLayer*(self: CombinedItem): int =
|
||||
return self.layer
|
||||
|
||||
proc getShortName*(self: CombinedItem, areTestNetworksEnabled: bool): string =
|
||||
if areTestNetworksEnabled:
|
||||
return self.test.shortName()
|
||||
else:
|
||||
return self.prod.shortName()
|
||||
|
||||
proc getChainId*(self: CombinedItem, areTestNetworksEnabled: bool): int =
|
||||
if areTestNetworksEnabled:
|
||||
return self.test.chainId()
|
||||
else:
|
||||
return self.prod.chainId()
|
|
@ -1,89 +0,0 @@
|
|||
import NimQml, Tables, strutils, stew/shims/strformat
|
||||
|
||||
import ./combined_item
|
||||
|
||||
type
|
||||
ModelRole* {.pure.} = enum
|
||||
Prod = UserRole + 1,
|
||||
Test
|
||||
Layer
|
||||
|
||||
QtObject:
|
||||
type
|
||||
CombinedModel* = ref object of QAbstractListModel
|
||||
items: seq[CombinedItem]
|
||||
|
||||
proc delete(self: CombinedModel) =
|
||||
self.items = @[]
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: CombinedModel) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newCombinedModel*(): CombinedModel =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc `$`*(self: CombinedModel): string =
|
||||
for i in 0 ..< self.items.len:
|
||||
result &= fmt"""[{i}]:({$self.items[i]})"""
|
||||
|
||||
proc countChanged(self: CombinedModel) {.signal.}
|
||||
|
||||
proc getCount(self: CombinedModel): int {.slot.} =
|
||||
self.items.len
|
||||
|
||||
QtProperty[int] count:
|
||||
read = getCount
|
||||
notify = countChanged
|
||||
|
||||
method rowCount*(self: CombinedModel, index: QModelIndex = nil): int =
|
||||
return self.items.len
|
||||
|
||||
method roleNames(self: CombinedModel): Table[int, string] =
|
||||
{
|
||||
ModelRole.Prod.int:"prod",
|
||||
ModelRole.Test.int:"test",
|
||||
ModelRole.Layer.int:"layer",
|
||||
}.toTable
|
||||
|
||||
method data(self: CombinedModel, index: QModelIndex, role: int): QVariant =
|
||||
if (not index.isValid):
|
||||
return
|
||||
|
||||
if (index.row < 0 or index.row >= self.items.len):
|
||||
return
|
||||
|
||||
let item = self.items[index.row]
|
||||
let enumRole = role.ModelRole
|
||||
|
||||
case enumRole:
|
||||
of ModelRole.Prod:
|
||||
result = newQVariant(item.getProd())
|
||||
of ModelRole.Test:
|
||||
result = newQVariant(item.getTest())
|
||||
of ModelRole.Layer:
|
||||
result = newQVariant(item.getLayer())
|
||||
|
||||
proc setItems*(self: CombinedModel, items: seq[CombinedItem]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
proc getAllNetworksChainIds*(self: CombinedModel, areTestNetworksEnabled: bool): string =
|
||||
var networks: seq[int] = @[]
|
||||
for item in self.items:
|
||||
networks.add(item.getChainId(areTestNetworksEnabled))
|
||||
return networks.join(":")
|
||||
|
||||
proc getNetworkShortNames*(self: CombinedModel, preferredNetworks: string, areTestNetworksEnabled: bool): string =
|
||||
var networkString = ""
|
||||
let networks = preferredNetworks.split(":")
|
||||
for nw in networks:
|
||||
for item in self.items:
|
||||
if $item.getChainId(areTestNetworksEnabled) == nw:
|
||||
networkString = networkString & $item.getShortName(areTestNetworksEnabled) & ':'
|
||||
break
|
||||
return networkString
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
import ../../../../../core/eventemitter
|
||||
import ../../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../../app_service/service/settings/service as settings_service
|
||||
import ./io_interface
|
||||
|
||||
|
||||
type
|
||||
Controller* = ref object of RootObj
|
||||
delegate: io_interface.AccessInterface
|
||||
events: EventEmitter
|
||||
networkService: network_service.Service
|
||||
walletAccountService: wallet_account_service.Service
|
||||
settingsService: settings_service.Service
|
||||
|
||||
proc newController*(
|
||||
delegate: io_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
networkService: network_service.Service,
|
||||
walletAccountService: wallet_account_service.Service,
|
||||
settingsService: settings_service.Service,
|
||||
): Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
result.events = events
|
||||
result.networkService = networkService
|
||||
result.walletAccountService = walletAccountService
|
||||
result.settingsService = settingsService
|
||||
|
||||
proc delete*(self: Controller) =
|
||||
discard
|
||||
|
||||
proc init*(self: Controller) =
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED) do(e: Args):
|
||||
let args = ChainIdForUrlArgs(e)
|
||||
self.delegate.chainIdFetchedForUrl(args.url, args.chainId, args.success, args.isMainUrl)
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
proc getCombinedNetworks*(self: Controller): seq[CombinedNetworkDto] =
|
||||
return self.networkService.getCombinedNetworks()
|
||||
|
||||
proc areTestNetworksEnabled*(self: Controller): bool =
|
||||
return self.settingsService.areTestNetworksEnabled()
|
||||
|
||||
proc toggleTestNetworksEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleTestNetworksEnabled()
|
||||
|
||||
proc isGoerliEnabled*(self: Controller): bool =
|
||||
return self.walletAccountService.isGoerliEnabled()
|
||||
|
||||
proc toggleIsGoerliEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleIsGoerliEnabled()
|
||||
|
||||
proc fetchChainIdForUrl*(self: Controller, url: string, isMainUrl: bool) =
|
||||
self.walletAccountService.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
proc updateNetworkEndPointValues*(self: Controller, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) =
|
||||
self.networkService.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
|
@ -1,41 +0,0 @@
|
|||
import NimQml
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for any input/interaction with this module.
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method load*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# View Delegate Interface
|
||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
||||
# inheritance, which is not well supported in Nim.
|
||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method refreshNetworks*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleTestNetworksEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleIsGoerliEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateNetworkEndPointValues*(self: AccessInterface, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method fetchChainIdForUrl*(self: AccessInterface, url: string, isMainUrl: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method chainIdFetchedForUrl*(self: AccessInterface, url: string, chainId: int, success: bool, isMainUrl: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -1,162 +0,0 @@
|
|||
import NimQml, stew/shims/strformat
|
||||
|
||||
QtObject:
|
||||
type Item* = ref object of QObject
|
||||
chainId: int
|
||||
layer: int
|
||||
chainName: string
|
||||
iconUrl: string
|
||||
shortName: string
|
||||
chainColor: string
|
||||
rpcURL: string
|
||||
fallbackURL: string
|
||||
originalRpcURL: string
|
||||
originalFallbackURL: string
|
||||
blockExplorerURL: string
|
||||
nativeCurrencySymbol: string
|
||||
|
||||
proc setup*(self: Item,
|
||||
chainId: int,
|
||||
layer: int,
|
||||
chainName: string,
|
||||
iconUrl: string,
|
||||
shortName: string,
|
||||
chainColor: string,
|
||||
rpcURL: string,
|
||||
fallbackURL: string,
|
||||
originalRpcURL: string,
|
||||
originalFallbackURL: string,
|
||||
blockExplorerURL: string,
|
||||
nativeCurrencySymbol: string
|
||||
) =
|
||||
self.QObject.setup
|
||||
self.chainId = chainId
|
||||
self.layer = layer
|
||||
self.chainName = chainName
|
||||
self.iconUrl = iconUrl
|
||||
self.shortName = shortName
|
||||
self.chainColor = chainColor
|
||||
self.rpcURL = rpcURL
|
||||
self.fallbackURL = fallbackURL
|
||||
self.originalRpcURL = originalRpcURL
|
||||
self.originalFallbackURL = originalFallbackURL
|
||||
self.blockExplorerURL = blockExplorerURL
|
||||
self.nativeCurrencySymbol = nativeCurrencySymbol
|
||||
|
||||
proc delete*(self: Item) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newItem*(
|
||||
chainId: int,
|
||||
layer: int,
|
||||
chainName: string,
|
||||
iconUrl: string,
|
||||
shortName: string,
|
||||
chainColor: string,
|
||||
rpcURL: string,
|
||||
fallbackURL: string,
|
||||
originalRpcURL: string,
|
||||
originalFallbackURL: string,
|
||||
blockExplorerURL: string,
|
||||
nativeCurrencySymbol: string
|
||||
): Item =
|
||||
new(result, delete)
|
||||
result.setup(chainId, layer, chainName, iconUrl, shortName, chainColor, rpcURL, fallbackURL, originalRpcURL, originalFallbackURL, blockExplorerURL, nativeCurrencySymbol)
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""NetworkItem(
|
||||
chainId: {self.chainId},
|
||||
chainName: {self.chainName},
|
||||
layer: {self.layer},
|
||||
iconUrl:{self.iconUrl},
|
||||
shortName: {self.shortName},
|
||||
chainColor: {self.chainColor},
|
||||
rpcURL: {self.rpcURL},
|
||||
fallbackURL: {self.fallbackURL},
|
||||
blockExplorerURL: {self.blockExplorerURL},
|
||||
nativeCurrencySymbol: {self.nativeCurrencySymbol},
|
||||
]"""
|
||||
|
||||
proc chainIdChanged*(self: Item) {.signal.}
|
||||
proc chainId*(self: Item): int {.slot.} =
|
||||
return self.chainId
|
||||
QtProperty[int] chainId:
|
||||
read = chainId
|
||||
notify = chainIdChanged
|
||||
|
||||
proc layerChanged*(self: Item) {.signal.}
|
||||
proc layer*(self: Item): int {.slot.} =
|
||||
return self.layer
|
||||
QtProperty[int] layer:
|
||||
read = layer
|
||||
notify = layerChanged
|
||||
|
||||
proc chainNameChanged*(self: Item) {.signal.}
|
||||
proc chainName*(self: Item): string {.slot.} =
|
||||
return self.chainName
|
||||
QtProperty[string] chainName:
|
||||
read = chainName
|
||||
notify = chainNameChanged
|
||||
|
||||
proc iconUrlChanged*(self: Item) {.signal.}
|
||||
proc iconUrl*(self: Item): string {.slot.} =
|
||||
return self.iconUrl
|
||||
QtProperty[string] iconUrl:
|
||||
read = iconUrl
|
||||
notify = iconUrlChanged
|
||||
|
||||
proc shortNameChanged*(self: Item) {.signal.}
|
||||
proc shortName*(self: Item): string {.slot.} =
|
||||
return self.shortName
|
||||
QtProperty[string] shortName:
|
||||
read = shortName
|
||||
notify = shortNameChanged
|
||||
|
||||
proc chainColorChanged*(self: Item) {.signal.}
|
||||
proc chainColor*(self: Item): string {.slot.} =
|
||||
return self.chainColor
|
||||
QtProperty[string] chainColor:
|
||||
read = chainColor
|
||||
notify = chainColorChanged
|
||||
|
||||
proc rpcURLChanged*(self: Item) {.signal.}
|
||||
proc rpcURL*(self: Item): string {.slot.} =
|
||||
return self.rpcURL
|
||||
QtProperty[string] rpcURL:
|
||||
read = rpcURL
|
||||
notify = rpcURLChanged
|
||||
|
||||
proc fallbackURLChanged*(self: Item) {.signal.}
|
||||
proc fallbackURL*(self: Item): string {.slot.} =
|
||||
return self.fallbackURL
|
||||
QtProperty[string] fallbackURL:
|
||||
read = fallbackURL
|
||||
notify = fallbackURLChanged
|
||||
|
||||
proc originalRpcURLChanged*(self: Item) {.signal.}
|
||||
proc originalRpcURL*(self: Item): string {.slot.} =
|
||||
return self.originalRpcURL
|
||||
QtProperty[string] originalRpcURL:
|
||||
read = originalRpcURL
|
||||
notify = originalRpcURLChanged
|
||||
|
||||
proc originalFallbackURLChanged*(self: Item) {.signal.}
|
||||
proc originalFallbackURL*(self: Item): string {.slot.} =
|
||||
return self.originalFallbackURL
|
||||
QtProperty[string] originalFallbackURL:
|
||||
read = originalFallbackURL
|
||||
notify = originalFallbackURLChanged
|
||||
|
||||
proc blockExplorerURLChanged*(self: Item) {.signal.}
|
||||
proc blockExplorerURL*(self: Item): string {.slot.} =
|
||||
return self.blockExplorerURL
|
||||
QtProperty[string] blockExplorerURL:
|
||||
read = blockExplorerURL
|
||||
notify = blockExplorerURLChanged
|
||||
|
||||
proc nativeCurrencySymbolChanged*(self: Item) {.signal.}
|
||||
proc nativeCurrencySymbol*(self: Item): string {.slot.} =
|
||||
return self.nativeCurrencySymbol
|
||||
QtProperty[string] nativeCurrencySymbol:
|
||||
read = nativeCurrencySymbol
|
||||
notify = nativeCurrencySymbolChanged
|
|
@ -1,96 +0,0 @@
|
|||
import NimQml, Tables, strutils, stew/shims/strformat
|
||||
|
||||
import ./item
|
||||
|
||||
type
|
||||
ModelRole* {.pure.} = enum
|
||||
ChainId = UserRole + 1,
|
||||
Layer
|
||||
ChainName
|
||||
IconUrl
|
||||
ShortName
|
||||
ChainColor
|
||||
|
||||
QtObject:
|
||||
type
|
||||
Model* = ref object of QAbstractListModel
|
||||
items: seq[Item]
|
||||
|
||||
proc delete(self: Model) =
|
||||
self.items = @[]
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: Model) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newModel*(): Model =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
|
||||
proc `$`*(self: Model): string =
|
||||
for i in 0 ..< self.items.len:
|
||||
result &= fmt"""[{i}]:({$self.items[i]})"""
|
||||
|
||||
proc countChanged(self: Model) {.signal.}
|
||||
|
||||
proc getCount(self: Model): int {.slot.} =
|
||||
self.items.len
|
||||
|
||||
QtProperty[int] count:
|
||||
read = getCount
|
||||
notify = countChanged
|
||||
|
||||
method rowCount*(self: Model, index: QModelIndex = nil): int =
|
||||
return self.items.len
|
||||
|
||||
method roleNames(self: Model): Table[int, string] =
|
||||
{
|
||||
ModelRole.ChainId.int:"chainId",
|
||||
ModelRole.Layer.int:"layer",
|
||||
ModelRole.ChainName.int:"chainName",
|
||||
ModelRole.IconUrl.int:"iconUrl",
|
||||
ModelRole.ShortName.int:"shortName",
|
||||
ModelRole.ChainColor.int:"chainColor",
|
||||
}.toTable
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
if (not index.isValid):
|
||||
return
|
||||
|
||||
if (index.row < 0 or index.row >= self.items.len):
|
||||
return
|
||||
|
||||
let item = self.items[index.row]
|
||||
let enumRole = role.ModelRole
|
||||
|
||||
case enumRole:
|
||||
of ModelRole.ChainId:
|
||||
result = newQVariant(item.chainId())
|
||||
of ModelRole.Layer:
|
||||
result = newQVariant(item.layer())
|
||||
of ModelRole.ChainName:
|
||||
result = newQVariant(item.chainName())
|
||||
of ModelRole.IconUrl:
|
||||
result = newQVariant(item.iconURL())
|
||||
of ModelRole.ShortName:
|
||||
result = newQVariant(item.shortName())
|
||||
of ModelRole.ChainColor:
|
||||
result = newQVariant(item.chainColor())
|
||||
|
||||
proc rowData*(self: Model, index: int, column: string): string {.slot.} =
|
||||
if (index >= self.items.len):
|
||||
return
|
||||
let item = self.items[index]
|
||||
case column:
|
||||
of "chainId": result = $item.chainId()
|
||||
of "layer": result = $item.layer()
|
||||
of "chainName": result = $item.chainName()
|
||||
of "iconUrl": result = $item.iconURL()
|
||||
of "shortName": result = $item.shortName()
|
||||
of "chainColor": result = $item.chainColor()
|
||||
|
||||
proc setItems*(self: Model, items: seq[Item]) =
|
||||
self.beginResetModel()
|
||||
self.items = items
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
|
@ -1,115 +0,0 @@
|
|||
import NimQml
|
||||
import ../io_interface as delegate_interface
|
||||
import io_interface, view, controller, combined_item, item
|
||||
import ../../../../../core/eventemitter
|
||||
import ../../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../../app_service/service/settings/service as settings_service
|
||||
|
||||
export io_interface
|
||||
|
||||
type
|
||||
Module* = ref object of io_interface.AccessInterface
|
||||
delegate: delegate_interface.AccessInterface
|
||||
view: View
|
||||
viewVariant: QVariant
|
||||
controller: Controller
|
||||
moduleLoaded: bool
|
||||
|
||||
proc newModule*(
|
||||
delegate: delegate_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
networkService: networkService.Service,
|
||||
walletAccountService: wallet_account_service.Service,
|
||||
settingsService: settings_service.Service,
|
||||
): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
result.view = view.newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController(result, events, networkService, walletAccountService, settingsService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.view.delete
|
||||
self.viewVariant.delete
|
||||
self.controller.delete
|
||||
|
||||
method getModuleAsVariant*(self: Module): QVariant =
|
||||
return self.viewVariant
|
||||
|
||||
method refreshNetworks*(self: Module) =
|
||||
var items: seq[Item] = @[]
|
||||
var combinedItems: seq[CombinedItem] = @[]
|
||||
for n in self.controller.getCombinedNetworks():
|
||||
var prod = newItem(
|
||||
n.prod.chainId,
|
||||
n.prod.layer,
|
||||
n.prod.chainName,
|
||||
n.prod.iconUrl,
|
||||
n.prod.shortName,
|
||||
n.prod.chainColor,
|
||||
n.prod.rpcURL,
|
||||
n.prod.fallbackURL,
|
||||
n.prod.originalRpcURL,
|
||||
n.prod.originalFallbackURL,
|
||||
n.prod.blockExplorerURL,
|
||||
n.prod.nativeCurrencySymbol
|
||||
)
|
||||
var test = newItem(
|
||||
n.test.chainId,
|
||||
n.test.layer,
|
||||
n.test.chainName,
|
||||
n.test.iconUrl,
|
||||
n.test.shortName,
|
||||
n.test.chainColor,
|
||||
n.test.rpcURL,
|
||||
n.test.fallbackURL,
|
||||
n.test.originalRpcURL,
|
||||
n.test.originalFallbackURL,
|
||||
n.test.blockExplorerURL,
|
||||
n.test.nativeCurrencySymbol
|
||||
)
|
||||
if self.controller.areTestNetworksEnabled():
|
||||
items.add(test)
|
||||
else:
|
||||
items.add(prod)
|
||||
combinedItems.add(initCombinedItem(prod,test,n.prod.layer))
|
||||
self.view.setItems(items, combinedItems)
|
||||
|
||||
method load*(self: Module) =
|
||||
self.controller.init()
|
||||
self.view.load()
|
||||
self.view.setAreTestNetworksEnabled(self.controller.areTestNetworksEnabled())
|
||||
self.view.setIsGoerliEnabled(self.controller.isGoerliEnabled())
|
||||
self.refreshNetworks()
|
||||
|
||||
method isLoaded*(self: Module): bool =
|
||||
return self.moduleLoaded
|
||||
|
||||
proc checkIfModuleDidLoad(self: Module) =
|
||||
self.moduleLoaded = true
|
||||
self.delegate.networksModuleDidLoad()
|
||||
|
||||
method viewDidLoad*(self: Module) =
|
||||
self.checkIfModuleDidLoad()
|
||||
|
||||
proc areTestNetworksEnabled*(self: Module): bool =
|
||||
return self.controller.areTestNetworksEnabled()
|
||||
|
||||
method toggleTestNetworksEnabled*(self: Module) =
|
||||
self.controller.toggleTestNetworksEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method toggleIsGoerliEnabled*(self: Module) =
|
||||
self.controller.toggleIsGoerliEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method updateNetworkEndPointValues*(self: Module, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) =
|
||||
self.controller.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
|
||||
method fetchChainIdForUrl*(self: Module, url: string, isMainUrl: bool) =
|
||||
self.controller.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
method chainIdFetchedForUrl*(self: Module, url: string, chainId: int, success: bool, isMainUrl: bool) =
|
||||
self.view.chainIdFetchedForUrl(url, chainId, success, isMainUrl)
|
|
@ -1,101 +0,0 @@
|
|||
import NimQml, sequtils
|
||||
|
||||
import ./io_interface
|
||||
import ./item
|
||||
import ./model
|
||||
import ./combined_item
|
||||
import ./combined_model
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
delegate: io_interface.AccessInterface
|
||||
combinedNetworks: CombinedModel
|
||||
networks: Model
|
||||
areTestNetworksEnabled: bool
|
||||
isGoerliEnabled: bool
|
||||
|
||||
proc setup(self: View) =
|
||||
self.QObject.setup
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.combinedNetworks.delete
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||
new(result, delete)
|
||||
result.delegate = delegate
|
||||
result.combinedNetworks = newCombinedModel()
|
||||
result.networks = newModel()
|
||||
result.setup()
|
||||
|
||||
proc areTestNetworksEnabledChanged*(self: View) {.signal.}
|
||||
|
||||
proc getAreTestNetworksEnabled(self: View): bool {.slot.} =
|
||||
return self.areTestNetworksEnabled
|
||||
|
||||
QtProperty[bool] areTestNetworksEnabled:
|
||||
read = getAreTestNetworksEnabled
|
||||
notify = areTestNetworksEnabledChanged
|
||||
|
||||
proc setAreTestNetworksEnabled*(self: View, areTestNetworksEnabled: bool) =
|
||||
self.areTestNetworksEnabled = areTestNetworksEnabled
|
||||
self.areTestNetworksEnabledChanged()
|
||||
|
||||
proc toggleTestNetworksEnabled*(self: View) {.slot.} =
|
||||
self.delegate.toggleTestNetworksEnabled()
|
||||
self.areTestNetworksEnabled = not self.areTestNetworksEnabled
|
||||
self.areTestNetworksEnabledChanged()
|
||||
|
||||
proc isGoerliEnabledChanged*(self: View) {.signal.}
|
||||
|
||||
proc getIsGoerliEnabled(self: View): bool {.slot.} =
|
||||
return self.isGoerliEnabled
|
||||
|
||||
QtProperty[bool] isGoerliEnabled:
|
||||
read = getIsGoerliEnabled
|
||||
notify = isGoerliEnabledChanged
|
||||
|
||||
proc setIsGoerliEnabled*(self: View, IsGoerliEnabled: bool) =
|
||||
self.isGoerliEnabled = IsGoerliEnabled
|
||||
self.isGoerliEnabledChanged()
|
||||
|
||||
proc toggleIsGoerliEnabled*(self: View) {.slot.} =
|
||||
self.delegate.toggleIsGoerliEnabled()
|
||||
self.isGoerliEnabled = not self.isGoerliEnabled
|
||||
self.isGoerliEnabledChanged()
|
||||
|
||||
proc networksChanged*(self: View) {.signal.}
|
||||
proc getNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.networks)
|
||||
QtProperty[QVariant] networks:
|
||||
read = getNetworks
|
||||
notify = networksChanged
|
||||
|
||||
proc combinedNetworksChanged*(self: View) {.signal.}
|
||||
proc getCombinedNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.combinedNetworks)
|
||||
QtProperty[QVariant] combinedNetworks:
|
||||
read = getCombinedNetworks
|
||||
notify = combinedNetworksChanged
|
||||
|
||||
proc load*(self: View) =
|
||||
self.delegate.viewDidLoad()
|
||||
|
||||
proc setItems*(self: View, items: seq[Item], combinedItems: seq[CombinedItem]) =
|
||||
self.networks.setItems(items)
|
||||
self.combinedNetworks.setItems(combinedItems)
|
||||
|
||||
proc getAllNetworksChainIds*(self: View): string {.slot.} =
|
||||
return self.combinedNetworks.getAllNetworksChainIds(self.areTestNetworksEnabled)
|
||||
|
||||
proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} =
|
||||
return self.combinedNetworks.getNetworkShortNames(preferredNetworks, self.areTestNetworksEnabled)
|
||||
|
||||
proc updateNetworkEndPointValues*(self: View, chainId: int, newMainRpcInput: string, newFailoverRpcUrl: string, revertToDefault: bool) {.slot.} =
|
||||
self.delegate.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
|
||||
proc fetchChainIdForUrl*(self: View, url: string, isMainUrl: bool) {.slot.} =
|
||||
self.delegate.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
proc chainIdFetchedForUrl*(self: View, url: string, chainId: int, success: bool, isMainUrl: bool) {.signal.}
|
|
@ -21,11 +21,6 @@ QtObject:
|
|||
QtProperty[QVariant] accountsModule:
|
||||
read = getAccountsModule
|
||||
|
||||
proc getNetworksModule(self: View): QVariant {.slot.} =
|
||||
return self.delegate.getNetworksModule()
|
||||
QtProperty[QVariant] networksModule:
|
||||
read = getNetworksModule
|
||||
|
||||
proc getCollectiblesModel(self: View): QVariant {.slot.} =
|
||||
return self.delegate.getCollectiblesModel()
|
||||
QtProperty[QVariant] collectiblesModel:
|
||||
|
|
|
@ -12,6 +12,7 @@ import app_service/service/wallet_account/service as wallet_account_service
|
|||
import app_service/service/token/service as token_service
|
||||
import app_service/service/keycard/service as keycard_service
|
||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app_service/service/network/network_item
|
||||
|
||||
const UNIQUE_BUY_STICKER_TRANSACTION_MODULE_IDENTIFIER* = "StickersSection-TransactionModule"
|
||||
|
||||
|
@ -170,7 +171,7 @@ proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto
|
|||
proc getCurrentCurrency*(self: Controller): string =
|
||||
return self.settingsService.getCurrency()
|
||||
|
||||
proc getAppNetwork*(self: Controller): NetworkDto =
|
||||
proc getAppNetwork*(self: Controller): NetworkItem =
|
||||
return self.networkService.getAppNetwork()
|
||||
|
||||
proc getStatusTokenKey*(self: Controller): string =
|
||||
|
|
|
@ -8,7 +8,6 @@ import chat_search_model
|
|||
import ephemeral_notification_model
|
||||
from app_service/common/conversion import intToEnum
|
||||
from app_service/common/types import StatusType
|
||||
import app_service/service/network/dto as network_dto
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
|
|
@ -40,7 +40,7 @@ proc deleteAccount*(self: Controller, address: string) =
|
|||
self.walletAccountService.deleteAccount(address)
|
||||
|
||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.isEnabled).map(n => n.chainId)
|
||||
|
||||
proc getCurrentCurrency*(self: Controller): string =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import sequtils, sugar
|
||||
import io_interface
|
||||
import ../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../app_service/service/currency/service as currency_service
|
||||
import ../../../../app_service/service/network/service as network_service
|
||||
import app_service/service/settings/service as settings_service
|
||||
import app_service/service/wallet_account/service as wallet_account_service
|
||||
import app_service/service/currency/service as currency_service
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/network/network_item
|
||||
|
||||
import ../../shared/wallet_utils
|
||||
import ../../shared_models/currency_amount
|
||||
|
@ -54,14 +55,14 @@ proc getCurrencyAmount*(self: Controller, amount: float64, symbol: string): Curr
|
|||
proc updateCurrency*(self: Controller, currency: string) =
|
||||
self.walletAccountService.updateCurrency(currency)
|
||||
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkItem] =
|
||||
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.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.isEnabled).map(n => n.chainId)
|
||||
|
||||
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
|
||||
return self.walletAccountService.getKeypairByAccountAddress(address)
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
import NimQml, Tables, strutils
|
||||
|
||||
import ./io_interface
|
||||
|
||||
type
|
||||
ModelRole* {.pure.} = enum
|
||||
Prod = UserRole + 1,
|
||||
Test
|
||||
Layer
|
||||
|
||||
QtObject:
|
||||
type
|
||||
CombinedModel* = ref object of QAbstractListModel
|
||||
delegate: io_interface.NetworksDataSource
|
||||
|
||||
proc delete(self: CombinedModel) =
|
||||
self.QAbstractListModel.delete
|
||||
|
||||
proc setup(self: CombinedModel) =
|
||||
self.QAbstractListModel.setup
|
||||
|
||||
proc newCombinedModel*(delegate: io_interface.NetworksDataSource): CombinedModel =
|
||||
new(result, delete)
|
||||
result.setup
|
||||
result.delegate = delegate
|
||||
|
||||
proc countChanged(self: CombinedModel) {.signal.}
|
||||
proc getCount(self: CombinedModel): int {.slot.} =
|
||||
return self.delegate.getCombinedNetworksList().len
|
||||
QtProperty[int] count:
|
||||
read = getCount
|
||||
notify = countChanged
|
||||
|
||||
method rowCount*(self: CombinedModel, index: QModelIndex = nil): int =
|
||||
return self.delegate.getCombinedNetworksList().len
|
||||
|
||||
method roleNames(self: CombinedModel): Table[int, string] =
|
||||
{
|
||||
ModelRole.Prod.int:"prod",
|
||||
ModelRole.Test.int:"test",
|
||||
ModelRole.Layer.int:"layer",
|
||||
}.toTable
|
||||
|
||||
method data(self: CombinedModel, index: QModelIndex, role: int): QVariant =
|
||||
if (not index.isValid):
|
||||
return
|
||||
|
||||
if (index.row < 0 or index.row >= self.rowCount()):
|
||||
return
|
||||
|
||||
let item = self.delegate.getCombinedNetworksList()[index.row]
|
||||
let enumRole = role.ModelRole
|
||||
|
||||
case enumRole:
|
||||
of ModelRole.Prod:
|
||||
result = newQVariant(item.prod)
|
||||
of ModelRole.Test:
|
||||
result = newQVariant(item.test)
|
||||
of ModelRole.Layer:
|
||||
result = newQVariant(item.prod.layer)
|
||||
|
||||
proc modelUpdated*(self: CombinedModel) =
|
||||
self.beginResetModel()
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
|
@ -1,7 +1,9 @@
|
|||
import ../../../../core/eventemitter
|
||||
import ../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import app/core/eventemitter
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/wallet_account/service as wallet_account_service
|
||||
import app_service/service/settings/service as settings_service
|
||||
import app_service/service/network/network_item
|
||||
import app_service/service/network/combined_network_item
|
||||
import ./io_interface
|
||||
|
||||
|
||||
|
@ -32,13 +34,38 @@ proc delete*(self: Controller) =
|
|||
|
||||
proc init*(self: Controller) =
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED) do(e: Args):
|
||||
let args = ChainIdForUrlArgs(e)
|
||||
self.delegate.chainIdFetchedForUrl(args.url, args.chainId, args.success, args.isMainUrl)
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
|
||||
self.delegate.refreshNetworks()
|
||||
|
||||
proc getFlatNetworks*(self: Controller): var seq[NetworkDto] =
|
||||
proc getFlatNetworks*(self: Controller): var seq[NetworkItem] =
|
||||
return self.networkService.getFlatNetworks()
|
||||
|
||||
proc getCombinedNetworks*(self: Controller): var seq[CombinedNetworkItem] =
|
||||
return self.networkService.getCombinedNetworks()
|
||||
|
||||
proc setNetworksState*(self: Controller, chainIds: seq[int], enabled: bool) =
|
||||
self.walletAccountService.setNetworksState(chainIds, enabled)
|
||||
|
||||
proc areTestNetworksEnabled*(self: Controller): bool =
|
||||
return self.settingsService.areTestNetworksEnabled()
|
||||
|
||||
proc toggleTestNetworksEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleTestNetworksEnabled()
|
||||
|
||||
proc isGoerliEnabled*(self: Controller): bool =
|
||||
return self.walletAccountService.isGoerliEnabled()
|
||||
|
||||
proc toggleIsGoerliEnabled*(self: Controller) =
|
||||
self.walletAccountService.toggleIsGoerliEnabled()
|
||||
|
||||
proc updateNetworkEndPointValues*(self: Controller, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) =
|
||||
self.networkService.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
|
||||
proc fetchChainIdForUrl*(self: Controller, url: string, isMainUrl: bool) =
|
||||
self.walletAccountService.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import app_service/service/network/dto
|
||||
import app_service/service/network/network_item
|
||||
import app_service/service/network/combined_network_item
|
||||
|
||||
type
|
||||
NetworksDataSource* = tuple[
|
||||
getFlatNetworksList: proc(): var seq[NetworkDto]
|
||||
getFlatNetworksList: proc(): var seq[NetworkItem],
|
||||
getCombinedNetworksList: proc(): var seq[CombinedNetworkItem]
|
||||
]
|
||||
|
||||
type
|
||||
|
@ -24,11 +26,26 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleTestNetworksEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleIsGoerliEnabled*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setNetworksState*(self: AccessInterface, chainIds: seq[int], enable: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method refreshNetworks*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateNetworkEndPointValues*(self: AccessInterface, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method fetchChainIdForUrl*(self: AccessInterface, url: string, isMainUrl: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method chainIdFetchedForUrl*(self: AccessInterface, url: string, chainId: int, success: bool, isMainUrl: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getNetworksDataSource*(self: AccessInterface): NetworksDataSource {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -8,19 +8,22 @@ const EXPLORER_TX_PREFIX* = "/tx/"
|
|||
type
|
||||
ModelRole* {.pure.} = enum
|
||||
ChainId = UserRole + 1,
|
||||
NativeCurrencyDecimals
|
||||
Layer
|
||||
ChainName
|
||||
RpcURL
|
||||
BlockExplorerURL
|
||||
NativeCurrencyName
|
||||
NativeCurrencySymbol
|
||||
NativeCurrencyDecimals
|
||||
IsTest
|
||||
IsEnabled
|
||||
IconUrl
|
||||
ChainColor
|
||||
ShortName
|
||||
EnabledState
|
||||
FallbackURL
|
||||
OriginalRpcURL
|
||||
OriginalFallbackURL
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
@ -66,6 +69,9 @@ QtObject:
|
|||
ModelRole.ShortName.int: "shortName",
|
||||
ModelRole.ChainColor.int: "chainColor",
|
||||
ModelRole.EnabledState.int: "enabledState",
|
||||
ModelRole.FallbackURL.int: "fallbackURL",
|
||||
ModelRole.OriginalRpcURL.int: "originalRpcURL",
|
||||
ModelRole.OriginalFallbackURL.int: "originalFallbackURL",
|
||||
}.toTable
|
||||
|
||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -98,7 +104,7 @@ QtObject:
|
|||
of ModelRole.IsTest:
|
||||
result = newQVariant(item.isTest)
|
||||
of ModelRole.IsEnabled:
|
||||
result = newQVariant(item.enabled)
|
||||
result = newQVariant(item.isEnabled)
|
||||
of ModelRole.IconUrl:
|
||||
result = newQVariant(item.iconURL)
|
||||
of ModelRole.ShortName:
|
||||
|
@ -107,6 +113,12 @@ QtObject:
|
|||
result = newQVariant(item.chainColor)
|
||||
of ModelRole.EnabledState:
|
||||
result = newQVariant(item.enabledState.int)
|
||||
of ModelRole.FallbackURL:
|
||||
result = newQVariant(item.fallbackURL)
|
||||
of ModelRole.OriginalRpcURL:
|
||||
result = newQVariant(item.originalRpcURL)
|
||||
of ModelRole.OriginalFallbackURL:
|
||||
result = newQVariant(item.originalFallbackURL)
|
||||
|
||||
proc rowData*(self: Model, index: int, column: string): string {.slot.} =
|
||||
if (index >= self.rowCount()):
|
||||
|
@ -122,15 +134,19 @@ QtObject:
|
|||
of "nativeCurrencyName": result = $item.nativeCurrencyName
|
||||
of "nativeCurrencySymbol": result = $item.nativeCurrencySymbol
|
||||
of "isTest": result = $item.isTest
|
||||
of "isEnabled": result = $item.enabled
|
||||
of "isEnabled": result = $item.isEnabled
|
||||
of "iconUrl": result = $item.iconURL
|
||||
of "chainColor": result = $item.chainColor
|
||||
of "shortName": result = $item.shortName
|
||||
of "enabledState": result = $item.enabledState.int
|
||||
of "fallbackURL": result = $item.fallbackURL
|
||||
of "originalRpcURL": result = $item.originalRpcURL
|
||||
of "originalFallbackURL": result = $item.originalFallbackURL
|
||||
|
||||
proc refreshModel*(self: Model) =
|
||||
self.beginResetModel()
|
||||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
proc getBlockExplorerURL*(self: Model, chainId: int): string =
|
||||
for item in self.delegate.getFlatNetworksList():
|
||||
|
@ -198,4 +214,4 @@ QtObject:
|
|||
return networkIds
|
||||
|
||||
proc getEnabledChainIds*(self: Model, areTestNetworksEnabled: bool): string =
|
||||
return self.delegate.getFlatNetworksList().filter(n => n.enabled and n.isTest == areTestNetworksEnabled).map(n => n.chainId).join(":")
|
||||
return self.delegate.getFlatNetworksList().filter(n => n.isEnabled and n.isTest == areTestNetworksEnabled).map(n => n.chainId).join(":")
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import NimQml
|
||||
import ../io_interface as delegate_interface
|
||||
import io_interface, view, controller
|
||||
import ../../../../global/global_singleton
|
||||
import ../../../../core/eventemitter
|
||||
import ../../../../../app_service/service/network/service as network_service
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
import ../../../../../app_service/service/settings/service as settings_service
|
||||
import app/global/global_singleton
|
||||
import app/core/eventemitter
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/wallet_account/service as wallet_account_service
|
||||
import app_service/service/settings/service as settings_service
|
||||
import app_service/service/network/network_item
|
||||
import app_service/service/network/combined_network_item
|
||||
|
||||
export io_interface
|
||||
|
||||
|
@ -60,12 +62,30 @@ proc checkIfModuleDidLoad(self: Module) =
|
|||
method viewDidLoad*(self: Module) =
|
||||
self.checkIfModuleDidLoad()
|
||||
|
||||
method toggleTestNetworksEnabled*(self: Module) =
|
||||
self.controller.toggleTestNetworksEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method toggleIsGoerliEnabled*(self: Module) =
|
||||
self.controller.toggleIsGoerliEnabled()
|
||||
self.refreshNetworks()
|
||||
|
||||
method setNetworksState*(self: Module, chainIds: seq[int], enabled: bool) =
|
||||
self.controller.setNetworksState(chainIds, enabled)
|
||||
|
||||
method updateNetworkEndPointValues*(self: Module, chainId: int, newMainRpcInput, newFailoverRpcUrl: string, revertToDefault: bool) =
|
||||
self.controller.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
|
||||
method fetchChainIdForUrl*(self: Module, url: string, isMainUrl: bool) =
|
||||
self.controller.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
method chainIdFetchedForUrl*(self: Module, url: string, chainId: int, success: bool, isMainUrl: bool) =
|
||||
self.view.chainIdFetchedForUrl(url, chainId, success, isMainUrl)
|
||||
|
||||
# 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()
|
||||
getFlatNetworksList: proc(): var seq[NetworkItem] = self.controller.getFlatNetworks(),
|
||||
getCombinedNetworksList: proc(): var seq[CombinedNetworkItem] = self.controller.getCombinedNetworks()
|
||||
)
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import NimQml, sequtils, strutils
|
||||
|
||||
import ./io_interface
|
||||
import ./model
|
||||
import ./io_interface, ./model, ./combined_model
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
delegate: io_interface.AccessInterface
|
||||
flatNetworks: Model
|
||||
combinedNetworks: CombinedModel
|
||||
areTestNetworksEnabled: bool
|
||||
enabledChainIds: string
|
||||
isGoerliEnabled: bool
|
||||
|
||||
proc setup(self: View) =
|
||||
self.QObject.setup
|
||||
|
@ -21,6 +22,7 @@ QtObject:
|
|||
new(result, delete)
|
||||
result.delegate = delegate
|
||||
result.flatNetworks = newModel(delegate.getNetworksDataSource())
|
||||
result.combinedNetworks = newCombinedModel(delegate.getNetworksDataSource())
|
||||
result.enabledChainIds = ""
|
||||
result.setup()
|
||||
|
||||
|
@ -37,6 +39,9 @@ QtObject:
|
|||
self.areTestNetworksEnabled = areTestNetworksEnabled
|
||||
self.areTestNetworksEnabledChanged()
|
||||
|
||||
proc toggleTestNetworksEnabled*(self: View) {.slot.} =
|
||||
self.delegate.toggleTestNetworksEnabled()
|
||||
|
||||
proc flatNetworksChanged*(self: View) {.signal.}
|
||||
proc getFlatNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.flatNetworks)
|
||||
|
@ -44,6 +49,13 @@ QtObject:
|
|||
read = getFlatNetworks
|
||||
notify = flatNetworksChanged
|
||||
|
||||
proc combinedNetworksChanged*(self: View) {.signal.}
|
||||
proc getCombinedNetworks(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.combinedNetworks)
|
||||
QtProperty[QVariant] combinedNetworks:
|
||||
read = getCombinedNetworks
|
||||
notify = combinedNetworksChanged
|
||||
|
||||
proc enabledChainIdsChanged*(self: View) {.signal.}
|
||||
proc getEnabledChainIds(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.enabledChainIds)
|
||||
|
@ -51,8 +63,23 @@ QtObject:
|
|||
read = getEnabledChainIds
|
||||
notify = enabledChainIdsChanged
|
||||
|
||||
proc isGoerliEnabledChanged*(self: View) {.signal.}
|
||||
proc getIsGoerliEnabled(self: View): bool {.slot.} =
|
||||
return self.isGoerliEnabled
|
||||
QtProperty[bool] isGoerliEnabled:
|
||||
read = getIsGoerliEnabled
|
||||
notify = isGoerliEnabledChanged
|
||||
|
||||
proc setIsGoerliEnabled*(self: View, IsGoerliEnabled: bool) =
|
||||
self.isGoerliEnabled = IsGoerliEnabled
|
||||
self.isGoerliEnabledChanged()
|
||||
|
||||
proc toggleIsGoerliEnabled*(self: View) {.slot.} =
|
||||
self.delegate.toggleIsGoerliEnabled()
|
||||
|
||||
proc refreshModel*(self: View) =
|
||||
self.flatNetworks.refreshModel()
|
||||
self.combinedNetworks.modelUpdated()
|
||||
self.enabledChainIds = self.flatNetworks.getEnabledChainIds(self.areTestNetworksEnabled)
|
||||
self.flatNetworksChanged()
|
||||
self.enabledChainIdsChanged()
|
||||
|
@ -72,3 +99,11 @@ QtObject:
|
|||
|
||||
proc getBlockExplorerURL*(self: View, chainId: int): string {.slot.} =
|
||||
return self.flatNetworks.getBlockExplorerURL(chainId)
|
||||
|
||||
proc updateNetworkEndPointValues*(self: View, chainId: int, newMainRpcInput: string, newFailoverRpcUrl: string, revertToDefault: bool) {.slot.} =
|
||||
self.delegate.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
|
||||
proc fetchChainIdForUrl*(self: View, url: string, isMainUrl: bool) {.slot.} =
|
||||
self.delegate.fetchChainIdForUrl(url, isMainUrl)
|
||||
|
||||
proc chainIdFetchedForUrl*(self: View, url: string, chainId: int, success: bool, isMainUrl: bool) {.signal.}
|
||||
|
|
|
@ -7,6 +7,7 @@ import app_service/service/transaction/service as transaction_service
|
|||
import app_service/service/currency/service as currency_service
|
||||
import app_service/service/currency/dto as currency_dto
|
||||
import app_service/service/keycard/service as keycard_service
|
||||
import app_service/service/network/network_item
|
||||
|
||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app/modules/shared/wallet_utils
|
||||
|
@ -83,7 +84,7 @@ proc getChainIds*(self: Controller): seq[int] =
|
|||
return self.networkService.getCurrentNetworks().map(n => n.chainId)
|
||||
|
||||
proc getEnabledChainIds*(self: Controller): seq[int] =
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.isEnabled).map(n => n.chainId)
|
||||
|
||||
proc getCurrentCurrency*(self: Controller): string =
|
||||
return self.walletAccountService.getCurrency()
|
||||
|
@ -130,7 +131,7 @@ proc areTestNetworksEnabled*(self: Controller): bool =
|
|||
proc getTotalCurrencyBalance*(self: Controller, address: seq[string], chainIds: seq[int]): float64 =
|
||||
return self.walletAccountService.getTotalCurrencyBalance(address, chainIds)
|
||||
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkDto] =
|
||||
proc getCurrentNetworks*(self: Controller): seq[NetworkItem] =
|
||||
return self.networkService.getCurrentNetworks()
|
||||
|
||||
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
|
||||
|
|
|
@ -14,6 +14,7 @@ import app/modules/shared/wallet_utils
|
|||
import app_service/service/transaction/dto
|
||||
import app/modules/shared_models/currency_amount
|
||||
import app_service/service/token/service
|
||||
import app_service/service/network/network_item as network_service_item
|
||||
|
||||
import app/modules/shared_modules/collectibles/controller as collectiblesc
|
||||
import app/modules/shared_models/collectibles_model as collectibles
|
||||
|
@ -93,7 +94,7 @@ method delete*(self: Module) =
|
|||
self.nestedCollectiblesModel.delete
|
||||
self.collectiblesController.delete
|
||||
|
||||
proc convertSendToNetworkToNetworkItem(self: Module, network: SendToNetwork): NetworkItem =
|
||||
proc convertSendToNetworkToNetworkItem(self: Module, network: SendToNetwork): network_item.NetworkItem =
|
||||
result = initNetworkItem(
|
||||
network.chainId,
|
||||
network.chainName,
|
||||
|
@ -113,7 +114,7 @@ proc convertSendToNetworkToNetworkItem(self: Module, network: SendToNetwork): Ne
|
|||
amountIn = "",
|
||||
$network.amountOut)
|
||||
|
||||
proc convertNetworkDtoToNetworkItem(self: Module, network: NetworkDto): NetworkItem =
|
||||
proc convertNetworkDtoToNetworkItem(self: Module, network: network_service_item.NetworkItem): network_item.NetworkItem =
|
||||
result = initNetworkItem(
|
||||
network.chainId,
|
||||
network.chainName,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import app_service/service/network/dto as network_dto
|
||||
import app_service/service/network/network_item
|
||||
import ./collectibles_entry
|
||||
|
||||
proc getExtraData*(network: network_dto.NetworkDto): ExtraData =
|
||||
proc getExtraData*(network: NetworkItem): ExtraData =
|
||||
return ExtraData(
|
||||
networkShortName: network.shortName,
|
||||
networkColor: network.chainColor,
|
||||
networkIconUrl: network.iconURL
|
||||
)
|
||||
)
|
||||
|
|
|
@ -205,6 +205,14 @@ QtObject:
|
|||
read = preferredSharingChainIds
|
||||
notify = preferredSharingChainIdsChanged
|
||||
|
||||
proc `testPreferredChainIds=`*(self: WalletAccountItem, value: string) {.inline.} =
|
||||
self.testPreferredChainIds = value
|
||||
self.preferredSharingChainIdsChanged()
|
||||
|
||||
proc `prodPreferredChainIds=`*(self: WalletAccountItem, value: string) {.inline.} =
|
||||
self.prodPreferredChainIds = value
|
||||
self.preferredSharingChainIdsChanged()
|
||||
|
||||
proc hideFromTotalBalanceChanged*(self: WalletAccountItem) {.signal.}
|
||||
proc hideFromTotalBalance*(self: WalletAccountItem): bool {.slot.} =
|
||||
return self.hideFromTotalBalance
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import NimQml
|
||||
|
||||
import ./dto, ./network_item
|
||||
|
||||
QtObject:
|
||||
type CombinedNetworkItem* = ref object of QObject
|
||||
prod*: NetworkItem
|
||||
test*: NetworkItem
|
||||
layer*: int
|
||||
|
||||
proc setup*(self: CombinedNetworkItem,
|
||||
prod: NetworkItem,
|
||||
test: NetworkItem,
|
||||
layer: int
|
||||
) =
|
||||
self.QObject.setup
|
||||
self.prod = prod
|
||||
self.test = test
|
||||
self.layer = layer
|
||||
|
||||
proc delete*(self: CombinedNetworkItem) =
|
||||
self.QObject.delete
|
||||
|
||||
proc combinedNetworkDtoToCombinedItem*(combinedNetwork: CombinedNetworkDto): CombinedNetworkItem =
|
||||
new(result, delete)
|
||||
result.setup(networkDtoToItem(combinedNetwork.prod), networkDtoToItem(combinedNetwork.test), combinedNetwork.prod.layer)
|
|
@ -0,0 +1,178 @@
|
|||
import NimQml, stew/shims/strformat
|
||||
|
||||
import ./dto
|
||||
|
||||
QtObject:
|
||||
type NetworkItem* = ref object of QObject
|
||||
chainId*: int
|
||||
layer*: int
|
||||
chainName*: string
|
||||
iconUrl*: string
|
||||
shortName*: string
|
||||
chainColor*: string
|
||||
rpcURL*: string
|
||||
fallbackURL*: string
|
||||
originalRpcURL*: string
|
||||
originalFallbackURL*: string
|
||||
blockExplorerURL*: string
|
||||
nativeCurrencyName*: string
|
||||
nativeCurrencySymbol*: string
|
||||
nativeCurrencyDecimals*: int
|
||||
isTest*: bool
|
||||
isEnabled*: bool
|
||||
enabledState*: UxEnabledState
|
||||
relatedChainId*: int
|
||||
|
||||
proc setup*(self: NetworkItem,
|
||||
chainId: int,
|
||||
layer: int,
|
||||
chainName: string,
|
||||
iconUrl: string,
|
||||
shortName: string,
|
||||
chainColor: string,
|
||||
rpcURL: string,
|
||||
fallbackURL: string,
|
||||
originalRpcURL: string,
|
||||
originalFallbackURL: string,
|
||||
blockExplorerURL: string,
|
||||
nativeCurrencyName: string,
|
||||
nativeCurrencySymbol: string,
|
||||
nativeCurrencyDecimals: int,
|
||||
isTest: bool,
|
||||
isEnabled: bool,
|
||||
enabledState: UxEnabledState,
|
||||
relatedChainId: int
|
||||
) =
|
||||
self.QObject.setup
|
||||
self.chainId = chainId
|
||||
self.layer = layer
|
||||
self.chainName = chainName
|
||||
self.iconUrl = iconUrl
|
||||
self.shortName = shortName
|
||||
self.chainColor = chainColor
|
||||
self.rpcURL = rpcURL
|
||||
self.fallbackURL = fallbackURL
|
||||
self.originalRpcURL = originalRpcURL
|
||||
self.originalFallbackURL = originalFallbackURL
|
||||
self.blockExplorerURL = blockExplorerURL
|
||||
self.nativeCurrencyName = nativeCurrencyName
|
||||
self.nativeCurrencySymbol = nativeCurrencySymbol
|
||||
self.nativeCurrencyDecimals = nativeCurrencyDecimals
|
||||
self.isTest = isTest
|
||||
self.isEnabled = isEnabled
|
||||
self.enabledState = enabledState
|
||||
self.relatedChainId = relatedChainId
|
||||
|
||||
proc delete*(self: NetworkItem) =
|
||||
self.QObject.delete
|
||||
|
||||
proc networkDtoToItem*(network: NetworkDto): NetworkItem =
|
||||
new(result, delete)
|
||||
result.setup(network.chainId, network.layer, network.chainName, network.iconUrl, network.shortName,
|
||||
network.chainColor, network.rpcURL, network.fallbackURL, network.originalRpcURL, network.originalFallbackURL,
|
||||
network.blockExplorerURL, network.nativeCurrencyName, network.nativeCurrencySymbol, network.nativeCurrencyDecimals,
|
||||
network.isTest, network.enabled, network.enabledState, network.relatedChainId)
|
||||
|
||||
proc `$`*(self: NetworkItem): string =
|
||||
result = fmt"""NetworkItem(
|
||||
chainId: {self.chainId},
|
||||
chainName: {self.chainName},
|
||||
layer: {self.layer},
|
||||
iconUrl:{self.iconUrl},
|
||||
shortName: {self.shortName},
|
||||
chainColor: {self.chainColor},
|
||||
rpcURL: {self.rpcURL},
|
||||
fallbackURL: {self.fallbackURL},
|
||||
blockExplorerURL: {self.blockExplorerURL},
|
||||
nativeCurrencySymbol: {self.nativeCurrencySymbol},
|
||||
]"""
|
||||
|
||||
proc chainId*(self: NetworkItem): int {.slot.} =
|
||||
return self.chainId
|
||||
QtProperty[int] chainId:
|
||||
read = chainId
|
||||
|
||||
proc layer*(self: NetworkItem): int {.slot.} =
|
||||
return self.layer
|
||||
QtProperty[int] layer:
|
||||
read = layer
|
||||
|
||||
proc chainName*(self: NetworkItem): string {.slot.} =
|
||||
return self.chainName
|
||||
QtProperty[string] chainName:
|
||||
read = chainName
|
||||
|
||||
proc iconUrl*(self: NetworkItem): string {.slot.} =
|
||||
return self.iconUrl
|
||||
QtProperty[string] iconUrl:
|
||||
read = iconUrl
|
||||
|
||||
proc shortName*(self: NetworkItem): string {.slot.} =
|
||||
return self.shortName
|
||||
QtProperty[string] shortName:
|
||||
read = shortName
|
||||
|
||||
proc chainColor*(self: NetworkItem): string {.slot.} =
|
||||
return self.chainColor
|
||||
QtProperty[string] chainColor:
|
||||
read = chainColor
|
||||
|
||||
proc rpcURL*(self: NetworkItem): string {.slot.} =
|
||||
return self.rpcURL
|
||||
QtProperty[string] rpcURL:
|
||||
read = rpcURL
|
||||
|
||||
proc fallbackURL*(self: NetworkItem): string {.slot.} =
|
||||
return self.fallbackURL
|
||||
QtProperty[string] fallbackURL:
|
||||
read = fallbackURL
|
||||
|
||||
proc originalRpcURL*(self: NetworkItem): string {.slot.} =
|
||||
return self.originalRpcURL
|
||||
QtProperty[string] originalRpcURL:
|
||||
read = originalRpcURL
|
||||
|
||||
proc originalFallbackURL*(self: NetworkItem): string {.slot.} =
|
||||
return self.originalFallbackURL
|
||||
QtProperty[string] originalFallbackURL:
|
||||
read = originalFallbackURL
|
||||
|
||||
proc blockExplorerURL*(self: NetworkItem): string {.slot.} =
|
||||
return self.blockExplorerURL
|
||||
QtProperty[string] blockExplorerURL:
|
||||
read = blockExplorerURL
|
||||
|
||||
proc nativeCurrencySymbol*(self: NetworkItem): string {.slot.} =
|
||||
return self.nativeCurrencySymbol
|
||||
QtProperty[string] nativeCurrencySymbol:
|
||||
read = nativeCurrencySymbol
|
||||
|
||||
proc nativeCurrencyName*(self: NetworkItem): string {.slot.} =
|
||||
return self.nativeCurrencyName
|
||||
QtProperty[string] nativeCurrencyName:
|
||||
read = nativeCurrencyName
|
||||
|
||||
proc nativeCurrencyDecimals*(self: NetworkItem): int {.slot.} =
|
||||
return self.nativeCurrencyDecimals
|
||||
QtProperty[int] nativeCurrencyDecimals:
|
||||
read = nativeCurrencyDecimals
|
||||
|
||||
proc isTest*(self: NetworkItem): bool {.slot.} =
|
||||
return self.isTest
|
||||
QtProperty[bool] isTest:
|
||||
read = isTest
|
||||
|
||||
proc isEnabled*(self: NetworkItem): bool {.slot.} =
|
||||
return self.isEnabled
|
||||
QtProperty[bool] isEnabled:
|
||||
read = isEnabled
|
||||
|
||||
proc getEnabledState*(self: NetworkItem): int {.slot.} =
|
||||
return self.enabledState.int
|
||||
QtProperty[int] enabledState:
|
||||
read = getEnabledState
|
||||
|
||||
proc relatedChainId*(self: NetworkItem): int {.slot.} =
|
||||
return self.relatedChainId
|
||||
QtProperty[int] relatedChainId:
|
||||
read = relatedChainId
|
|
@ -3,6 +3,7 @@ import json, json_serialization, chronicles, sugar, sequtils
|
|||
import ../../../app/core/eventemitter
|
||||
import ../../../backend/backend as backend
|
||||
import ../settings/service as settings_service
|
||||
import ./network_item, ./combined_network_item
|
||||
|
||||
import dto, types
|
||||
|
||||
|
@ -21,8 +22,8 @@ type NetworkEndpointUpdatedArgs* = ref object of Args
|
|||
type
|
||||
Service* = ref object of RootObj
|
||||
events: EventEmitter
|
||||
combinedNetworks: seq[CombinedNetworkDto]
|
||||
flatNetworks: seq[NetworkDto]
|
||||
combinedNetworks: seq[CombinedNetworkItem]
|
||||
flatNetworks: seq[NetworkItem]
|
||||
settingsService: settings_service.Service
|
||||
|
||||
proc delete*(self: Service) =
|
||||
|
@ -33,18 +34,19 @@ proc newService*(events: EventEmitter, settingsService: settings_service.Service
|
|||
result.events = events
|
||||
result.settingsService = settingsService
|
||||
|
||||
proc fetchNetworks*(self: Service): seq[CombinedNetworkDto]=
|
||||
proc fetchNetworks*(self: Service): seq[CombinedNetworkItem]=
|
||||
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: @[]
|
||||
let combinedNetworksDto = if response.result.isNil or response.result.kind == JNull: @[]
|
||||
else: Json.decode($response.result, seq[CombinedNetworkDto], allowUnknownFields = true)
|
||||
result = combinedNetworksDto.map(x => x.combinedNetworkDtoToCombinedItem())
|
||||
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
|
||||
let allTestEnabled = self.combinedNetworks.filter(n => n.test.isEnabled).len == self.combinedNetworks.len
|
||||
let allProdEnabled = self.combinedNetworks.filter(n => n.prod.isEnabled).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)
|
||||
n.test.enabledState = networkEnabledToUxEnabledState(n.test.isEnabled, allTestEnabled)
|
||||
n.prod.enabledState = networkEnabledToUxEnabledState(n.prod.isEnabled, allProdEnabled)
|
||||
self.flatNetworks = @[]
|
||||
for network in self.combinedNetworks:
|
||||
self.flatNetworks.add(network.test)
|
||||
|
@ -56,17 +58,17 @@ proc init*(self: Service) =
|
|||
proc resetNetworks*(self: Service) =
|
||||
discard self.fetchNetworks()
|
||||
|
||||
proc getCombinedNetworks*(self: Service): seq[CombinedNetworkDto] =
|
||||
proc getCombinedNetworks*(self: Service): var seq[CombinedNetworkItem] =
|
||||
return self.combinedNetworks
|
||||
|
||||
proc getFlatNetworks*(self: Service): var seq[NetworkDto] =
|
||||
proc getFlatNetworks*(self: Service): var seq[NetworkItem] =
|
||||
return self.flatNetworks
|
||||
|
||||
# passes networks based on users choice of test/mainnet
|
||||
proc getCurrentNetworks*(self: Service): seq[NetworkDto] =
|
||||
proc getCurrentNetworks*(self: Service): seq[NetworkItem] =
|
||||
self.flatNetworks.filter(n => n.isTest == self.settingsService.areTestNetworksEnabled())
|
||||
|
||||
proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
||||
proc upsertNetwork*(self: Service, network: NetworkItem): bool =
|
||||
let response = backend.addEthereumChain(backend.Network(
|
||||
chainId: network.chainId,
|
||||
nativeCurrencyDecimals: network.nativeCurrencyDecimals,
|
||||
|
@ -81,17 +83,17 @@ proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
|||
nativeCurrencyName: network.nativeCurrencyName,
|
||||
nativeCurrencySymbol: network.nativeCurrencySymbol,
|
||||
isTest: network.isTest,
|
||||
enabled: network.enabled,
|
||||
enabled: network.isEnabled,
|
||||
chainColor: network.chainColor,
|
||||
shortName: network.shortName,
|
||||
relatedChainID: network.relatedChainID,
|
||||
relatedChainID: network.relatedChainId
|
||||
))
|
||||
return response.error == nil
|
||||
|
||||
proc deleteNetwork*(self: Service, network: NetworkDto) =
|
||||
proc deleteNetwork*(self: Service, network: NetworkItem) =
|
||||
discard backend.deleteEthereumChain(network.chainId)
|
||||
|
||||
proc getNetworkByChainId*(self: Service, chainId: int): NetworkDto =
|
||||
proc getNetworkByChainId*(self: Service, chainId: int): NetworkItem =
|
||||
var networks = self.combinedNetworks
|
||||
if self.combinedNetworks.len == 0:
|
||||
networks = self.fetchNetworks()
|
||||
|
@ -108,10 +110,10 @@ proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
|||
let network = self.getNetworkByChainId(chainId)
|
||||
|
||||
if not network.isNil:
|
||||
if network.enabled == enabled:
|
||||
if network.isEnabled == enabled:
|
||||
continue
|
||||
|
||||
network.enabled = enabled
|
||||
network.isEnabled = enabled
|
||||
discard self.upsertNetwork(network)
|
||||
discard self.fetchNetworks()
|
||||
|
||||
|
@ -125,7 +127,7 @@ proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
|||
## - Collectibles
|
||||
## - ENS names
|
||||
## - Browser
|
||||
proc getAppNetwork*(self: Service): NetworkDto =
|
||||
proc getAppNetwork*(self: Service): NetworkItem =
|
||||
var networkId = Mainnet
|
||||
if self.settingsService.areTestNetworksEnabled():
|
||||
networkId = Sepolia
|
||||
|
|
|
@ -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.getCurrentNetworks().filter(n => n.enabled and n.nativeCurrencySymbol == tokenSymbol).map(n => n.chainId)
|
||||
var chainIds: seq[int] = self.networkService.getCurrentNetworks().filter(n => n.isEnabled 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.getCurrentNetworks().filter(n => n.enabled).map(n => n.chainId)
|
||||
return self.networkService.getCurrentNetworks().filter(n => n.isEnabled).map(n => n.chainId)
|
||||
|
||||
proc getCurrencyFormat*(self: Service, symbol: string): CurrencyFormatDto =
|
||||
return self.currencyService.getCurrencyFormat(symbol)
|
||||
|
|
|
@ -6,7 +6,7 @@ QtObject {
|
|||
|
||||
property var advancedModule
|
||||
property var walletModule
|
||||
property var networksModule: root.walletModule.networksModule
|
||||
property var networksModuleInst: networksModule
|
||||
|
||||
// Advanced Module Properties
|
||||
property string fleet: advancedModule? advancedModule.fleet : ""
|
||||
|
@ -39,7 +39,7 @@ QtObject {
|
|||
readonly property real scrollVelocity: localAppSettings.scrollVelocity
|
||||
readonly property real scrollDeceleration: localAppSettings.scrollDeceleration
|
||||
|
||||
readonly property bool isGoerliEnabled: networksModule.isGoerliEnabled
|
||||
readonly property bool isGoerliEnabled: networksModuleInst.isGoerliEnabled
|
||||
|
||||
function logDir() {
|
||||
if(!root.advancedModule)
|
||||
|
|
|
@ -3,6 +3,7 @@ import QtQuick 2.13
|
|||
import utils 1.0
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
|
@ -11,23 +12,29 @@ QtObject {
|
|||
|
||||
property var walletModule
|
||||
property var accountsModule: root.walletModule.accountsModule
|
||||
property var networksModule: root.walletModule.networksModule
|
||||
property var networksModuleInst: networksModule
|
||||
property var collectibles: root.walletModule.collectiblesModel
|
||||
|
||||
property var accountSensitiveSettings: Global.appIsReady? localAccountSensitiveSettings : null
|
||||
property var dappList: Global.appIsReady? dappPermissionsModule.dapps : null
|
||||
|
||||
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
||||
readonly property bool isGoerliEnabled: networksModule.isGoerliEnabled
|
||||
readonly property bool areTestNetworksEnabled: networksModuleInst.areTestNetworksEnabled
|
||||
readonly property bool isGoerliEnabled: networksModuleInst.isGoerliEnabled
|
||||
|
||||
readonly property var combinedNetworks: networksModuleInst.combinedNetworks
|
||||
|
||||
property var flatNetworks: networksModuleInst.flatNetworks
|
||||
property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
||||
sourceModel: root.flatNetworks
|
||||
filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled }
|
||||
}
|
||||
|
||||
readonly property var networks: networksModule.networks
|
||||
readonly property var combinedNetworks: networksModule.combinedNetworks
|
||||
property var selectedAccount
|
||||
|
||||
property var networkRPCChanged: ({}) // add network id to the object if changed
|
||||
|
||||
function toggleTestNetworksEnabled(){
|
||||
networksModule.toggleTestNetworksEnabled()
|
||||
networksModuleInst.toggleTestNetworksEnabled()
|
||||
}
|
||||
// TODO(alaibe): there should be no access to wallet section, create collectible in profile
|
||||
property var overview: walletSectionOverview
|
||||
|
@ -38,7 +45,7 @@ QtObject {
|
|||
proxyRoles: FastExpressionRole {
|
||||
name: "preferredSharingChainShortNames"
|
||||
expression: {
|
||||
return root.networksModule.getNetworkShortNames(preferredSharingChainIds)
|
||||
return root.networksModuleInst.getNetworkShortNames(model.preferredSharingChainIds)
|
||||
}
|
||||
expectedRoles: ["preferredSharingChainIds"]
|
||||
}
|
||||
|
@ -76,7 +83,12 @@ QtObject {
|
|||
}
|
||||
|
||||
function getAllNetworksChainIds() {
|
||||
return networksModule.getAllNetworksChainIds()
|
||||
let result = []
|
||||
let chainIdsArray = ModelUtils.modelToFlatArray(root.filteredFlatModel, "chainId")
|
||||
for(let i = 0; i< chainIdsArray.length; i++) {
|
||||
result.push(chainIdsArray[i].toString())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function runAddAccountPopup() {
|
||||
|
@ -93,11 +105,11 @@ QtObject {
|
|||
}
|
||||
|
||||
function evaluateRpcEndPoint(url, isMainUrl) {
|
||||
return networksModule.fetchChainIdForUrl(url, isMainUrl)
|
||||
return networksModuleInst.fetchChainIdForUrl(url, isMainUrl)
|
||||
}
|
||||
|
||||
function updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault) {
|
||||
networksModule.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
networksModuleInst.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
||||
}
|
||||
|
||||
function updateWalletAccountPreferredChains(address, preferredChainIds) {
|
||||
|
@ -110,12 +122,12 @@ QtObject {
|
|||
}
|
||||
|
||||
function getNetworkShortNames(chainIds) {
|
||||
return networksModule.getNetworkShortNames(chainIds)
|
||||
return networksModuleInst.getNetworkShortNames(chainIds)
|
||||
}
|
||||
|
||||
function processPreferredSharingNetworkToggle(preferredSharingNetworks, toggledNetwork) {
|
||||
let prefChains = preferredSharingNetworks
|
||||
if(prefChains.length === networks.count) {
|
||||
if(prefChains.length === root.flatNetworks.count) {
|
||||
prefChains = [toggledNetwork.chainId.toString()]
|
||||
}
|
||||
else if(!prefChains.includes(toggledNetwork.chainId.toString())) {
|
||||
|
@ -123,7 +135,7 @@ QtObject {
|
|||
}
|
||||
else {
|
||||
if(prefChains.length === 1) {
|
||||
prefChains = getAllNetworksChainIds().split(":")
|
||||
prefChains = getAllNetworksChainIds()
|
||||
}
|
||||
else {
|
||||
for(var i = 0; i < prefChains.length;i++) {
|
||||
|
|
|
@ -261,7 +261,7 @@ SettingsContentBase {
|
|||
id: editNetwork
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
networksModule: root.walletStore.networksModule
|
||||
networksModule: root.walletStore.networksModuleInst
|
||||
networkRPCChanged: root.walletStore.networkRPCChanged
|
||||
onEvaluateRpcEndPoint: root.walletStore.evaluateRpcEndPoint(url, isMainUrl)
|
||||
onUpdateNetworkValues: {
|
||||
|
|
|
@ -256,7 +256,7 @@ ColumnLayout {
|
|||
color: Theme.palette.transparent
|
||||
components: [
|
||||
NetworkFilter {
|
||||
flatNetworks: root.walletStore.networks
|
||||
flatNetworks: root.walletStore.filteredFlatModel
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: d.preferredSharingNetworksArray
|
||||
onToggleNetwork: (network) => {
|
||||
|
|
Loading…
Reference in New Issue