From 4031778c7c9ebbbcde40a3d158e6db16adfa272b Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Tue, 20 Feb 2024 12:10:18 +0100 Subject: [PATCH] fix(@desktop/permissions): Use correct chains when creating permissions: testnet or mainnet Fix #18896 --- .gitignore | 1 + src/app/modules/main/chat_section/controller.nim | 10 +++++++++- src/app/modules/main/chat_section/module.nim | 4 +++- src/app/modules/main/controller.nim | 6 ++++++ src/app/modules/main/io_interface.nim | 4 ++++ src/app/modules/main/module.nim | 6 ++++++ vendor/status-go | 2 +- 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d3a3a78bc1..a4b4053f76 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ notarization.log status-desktop.log nim_status_client.log *.csv +.flatpak-builder # Squish test ================================================================ diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 5d3d723834..f50c1b110c 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -6,6 +6,7 @@ import ../../../../app_service/service/settings/service as settings_service import ../../../../app_service/service/node_configuration/service as node_configuration_service import ../../../../app_service/service/contacts/service as contact_service import ../../../../app_service/service/chat/service as chat_service +import ../../../../app_service/service/network/service as network_service import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/gif/service as gif_service @@ -42,6 +43,7 @@ type tokenService: token_service.Service communityTokensService: community_tokens_service.Service sharedUrlsService: shared_urls_service.Service + networkService: network_service.Service proc newController*(delegate: io_interface.AccessInterface, sectionId: string, isCommunity: bool, events: EventEmitter, @@ -51,7 +53,7 @@ proc newController*(delegate: io_interface.AccessInterface, sectionId: string, i gifService: gif_service.Service, mailserversService: mailservers_service.Service, walletAccountService: wallet_account_service.Service, tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, - sharedUrlsService: shared_urls_service.Service): Controller = + sharedUrlsService: shared_urls_service.Service, networkService: network_service.Service): Controller = result = Controller() result.delegate = delegate result.sectionId = sectionId @@ -70,6 +72,7 @@ proc newController*(delegate: io_interface.AccessInterface, sectionId: string, i result.tokenService = tokenService result.communityTokensService = communityTokensService result.sharedUrlsService = sharedUrlsService + result.networkService = networkService proc delete*(self: Controller) = self.events.disconnect() @@ -689,6 +692,11 @@ proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int, let token = self.tokenService.findTokenBySymbol(symbol) if token != nil: for addrPerChain in token.addressPerChainId: + # depending on areTestNetworksEnabled (in getNetwork), contractAddresses will + # contain mainnets or testnets only + let network = self.networkService.getNetwork(addrPerChain.chainId) + if network == nil: + continue contractAddresses[addrPerChain.chainId] = addrPerChain.address let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), symbol) if communityToken.address != "": diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 29e566de6a..872ece4ca6 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -24,6 +24,7 @@ import ../../../../app_service/service/settings/service as settings_service import ../../../../app_service/service/node_configuration/service as node_configuration_service import ../../../../app_service/service/contacts/service as contact_service import ../../../../app_service/service/chat/service as chat_service +import ../../../../app_service/service/network/service as network_service import ../../../../app_service/service/community/service as community_service import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/mailservers/service as mailservers_service @@ -103,12 +104,13 @@ proc newModule*( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: shared_urls_service.Service, + networkService: network_service.Service, ): Module = result = Module() result.delegate = delegate result.controller = controller.newController(result, sectionId, isCommunity, events, settingsService, nodeConfigurationService, contactService, chatService, communityService, messageService, gifService, - mailserversService, walletAccountService, tokenService, communityTokensService, sharedUrlsService) + mailserversService, walletAccountService, tokenService, communityTokensService, sharedUrlsService, networkService) result.view = view.newView(result) result.viewVariant = newQVariant(result.view) result.moduleLoaded = false diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 7a8bb6bf80..9206f7e67d 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -127,6 +127,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, ) self.events.on(SIGNAL_COMMUNITY_DATA_LOADED) do(e:Args): @@ -144,6 +145,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, ) self.events.on(SIGNAL_CHANNEL_GROUPS_LOADING_FAILED) do(e:Args): @@ -180,6 +182,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, setActive = args.fromUserAction ) @@ -200,6 +203,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, setActive = args.fromUserAction ) self.delegate.onFinaliseOwnershipStatusChanged(args.isPendingOwnershipRequest, args.community.id) @@ -226,6 +230,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, setActive = true ) @@ -248,6 +253,7 @@ proc init*(self: Controller) = self.tokenService, self.communityTokensService, self.sharedUrlsService, + self.networksService, setActive = false ) diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index f1a031a8b4..3f7f397c09 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -14,6 +14,7 @@ import app_service/service/token/service as token_service 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 from app_service/common/types import StatusType, ContractTransactionStatus, MembershipRequestState, Shard @@ -98,6 +99,7 @@ method onChannelGroupsLoaded*( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, ) {.base.} = raise newException(ValueError, "No implementation available") @@ -116,6 +118,7 @@ method onCommunityDataLoaded*( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, ){.base.} = raise newException(ValueError, "No implementation available") @@ -167,6 +170,7 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events: tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, setActive: bool = false, ) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index bbd2215b23..ce2b0df9f1 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -683,6 +683,7 @@ method onChannelGroupsLoaded*[T]( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, ) = self.chatsLoaded = true if not self.communityDataLoaded: @@ -710,6 +711,7 @@ method onChannelGroupsLoaded*[T]( tokenService, communityTokensService, sharedUrlsService, + networkService ) let channelGroupItem = self.createChannelGroupItem(channelGroup) self.view.model().addItem(channelGroupItem) @@ -744,6 +746,7 @@ method onCommunityDataLoaded*[T]( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, ) = self.communityDataLoaded = true if not self.chatsLoaded: @@ -764,6 +767,7 @@ method onCommunityDataLoaded*[T]( tokenService, communityTokensService, sharedUrlsService, + networkService, ) method onChatsLoadingFailed*[T](self: Module[T]) = @@ -1014,6 +1018,7 @@ method communityJoined*[T]( tokenService: token_service.Service, communityTokensService: community_tokens_service.Service, sharedUrlsService: urls_service.Service, + networkService: network_service.Service, setActive: bool = false, ) = if self.channelGroupModules.contains(community.id): @@ -1039,6 +1044,7 @@ method communityJoined*[T]( tokenService, communityTokensService, sharedUrlsService, + networkService ) let channelGroup = community.toChannelGroupDto() self.channelGroupModules[community.id].load() diff --git a/vendor/status-go b/vendor/status-go index 3959948c4c..ba7faea027 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 3959948c4c5ab560ae528c2d331241f2cc94fed1 +Subproject commit ba7faea027b1e87e6d53b0e487df2469cd6271f2