Skip to content

Commit

Permalink
fix(@desktop/wallet): Remove profile section's networks submodule and…
Browse files Browse the repository at this point in the history
… udpate logic for combined networks
  • Loading branch information
Khushboo-dev-cpp committed Mar 28, 2024
1 parent fd78a4d commit 55ccbb4
Show file tree
Hide file tree
Showing 48 changed files with 560 additions and 837 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/main/browser_section/provider/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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) =
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.} =
Expand Down
11 changes: 6 additions & 5 deletions src/app/modules/main/browser_section/provider/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/main/communities/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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] =
Expand Down Expand Up @@ -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) =
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/main/communities/tokens/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/main/communities/tokens/models/token_item.nim
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,7 +23,7 @@ type

proc initTokenItem*(
tokenDto: CommunityTokenDto,
network: NetworkDto,
network: NetworkItem,
tokenOwners: seq[CommunityCollectibleOwner],
accountName: string,
burnState: ContractTransactionStatus,
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/main/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) =
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/main/io_interface.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.} =
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/main/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) =
Expand Down
3 changes: 0 additions & 3 deletions src/app/modules/main/profile_section/profile/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions src/app/modules/main/profile_section/wallet/accounts/model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 0 additions & 6 deletions src/app/modules/main/profile_section/wallet/io_interface.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
14 changes: 0 additions & 14 deletions src/app/modules/main/profile_section/wallet/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*(
Expand All @@ -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
Expand All @@ -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()

Expand All @@ -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
Expand Down

This file was deleted.

Loading

0 comments on commit 55ccbb4

Please sign in to comment.