fix(@desktop/permissions): Use correct chains when creating permissions: testnet or mainnet

Fix #18896
This commit is contained in:
Michal Iskierko 2024-02-20 12:10:18 +01:00 committed by Jonathan Rainville
parent d6e13d709f
commit 4031778c7c
7 changed files with 30 additions and 3 deletions

1
.gitignore vendored
View File

@ -35,6 +35,7 @@ notarization.log
status-desktop.log status-desktop.log
nim_status_client.log nim_status_client.log
*.csv *.csv
.flatpak-builder
# Squish test ================================================================ # Squish test ================================================================

View File

@ -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/node_configuration/service as node_configuration_service
import ../../../../app_service/service/contacts/service as contact_service import ../../../../app_service/service/contacts/service as contact_service
import ../../../../app_service/service/chat/service as chat_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/community/service as community_service
import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/message/service as message_service
import ../../../../app_service/service/gif/service as gif_service import ../../../../app_service/service/gif/service as gif_service
@ -42,6 +43,7 @@ type
tokenService: token_service.Service tokenService: token_service.Service
communityTokensService: community_tokens_service.Service communityTokensService: community_tokens_service.Service
sharedUrlsService: shared_urls_service.Service sharedUrlsService: shared_urls_service.Service
networkService: network_service.Service
proc newController*(delegate: io_interface.AccessInterface, sectionId: string, isCommunity: bool, events: EventEmitter, 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, gifService: gif_service.Service, mailserversService: mailservers_service.Service,
walletAccountService: wallet_account_service.Service, tokenService: token_service.Service, walletAccountService: wallet_account_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_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 = Controller()
result.delegate = delegate result.delegate = delegate
result.sectionId = sectionId result.sectionId = sectionId
@ -70,6 +72,7 @@ proc newController*(delegate: io_interface.AccessInterface, sectionId: string, i
result.tokenService = tokenService result.tokenService = tokenService
result.communityTokensService = communityTokensService result.communityTokensService = communityTokensService
result.sharedUrlsService = sharedUrlsService result.sharedUrlsService = sharedUrlsService
result.networkService = networkService
proc delete*(self: Controller) = proc delete*(self: Controller) =
self.events.disconnect() self.events.disconnect()
@ -689,6 +692,11 @@ proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int,
let token = self.tokenService.findTokenBySymbol(symbol) let token = self.tokenService.findTokenBySymbol(symbol)
if token != nil: if token != nil:
for addrPerChain in token.addressPerChainId: for addrPerChain in token.addressPerChainId:
# depending on areTestNetworksEnabled (in getNetwork), contractAddresses will
# contain mainnets or testnets only
let network = self.networkService.getNetwork(addrPerChain.chainId)
if network == nil:
continue
contractAddresses[addrPerChain.chainId] = addrPerChain.address contractAddresses[addrPerChain.chainId] = addrPerChain.address
let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), symbol) let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), symbol)
if communityToken.address != "": if communityToken.address != "":

View File

@ -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/node_configuration/service as node_configuration_service
import ../../../../app_service/service/contacts/service as contact_service import ../../../../app_service/service/contacts/service as contact_service
import ../../../../app_service/service/chat/service as chat_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/community/service as community_service
import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/message/service as message_service
import ../../../../app_service/service/mailservers/service as mailservers_service import ../../../../app_service/service/mailservers/service as mailservers_service
@ -103,12 +104,13 @@ proc newModule*(
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: shared_urls_service.Service, sharedUrlsService: shared_urls_service.Service,
networkService: network_service.Service,
): Module = ): Module =
result = Module() result = Module()
result.delegate = delegate result.delegate = delegate
result.controller = controller.newController(result, sectionId, isCommunity, events, settingsService, result.controller = controller.newController(result, sectionId, isCommunity, events, settingsService,
nodeConfigurationService, contactService, chatService, communityService, messageService, gifService, nodeConfigurationService, contactService, chatService, communityService, messageService, gifService,
mailserversService, walletAccountService, tokenService, communityTokensService, sharedUrlsService) mailserversService, walletAccountService, tokenService, communityTokensService, sharedUrlsService, networkService)
result.view = view.newView(result) result.view = view.newView(result)
result.viewVariant = newQVariant(result.view) result.viewVariant = newQVariant(result.view)
result.moduleLoaded = false result.moduleLoaded = false

View File

@ -127,6 +127,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
) )
self.events.on(SIGNAL_COMMUNITY_DATA_LOADED) do(e:Args): self.events.on(SIGNAL_COMMUNITY_DATA_LOADED) do(e:Args):
@ -144,6 +145,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
) )
self.events.on(SIGNAL_CHANNEL_GROUPS_LOADING_FAILED) do(e:Args): self.events.on(SIGNAL_CHANNEL_GROUPS_LOADING_FAILED) do(e:Args):
@ -180,6 +182,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
setActive = args.fromUserAction setActive = args.fromUserAction
) )
@ -200,6 +203,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
setActive = args.fromUserAction setActive = args.fromUserAction
) )
self.delegate.onFinaliseOwnershipStatusChanged(args.isPendingOwnershipRequest, args.community.id) self.delegate.onFinaliseOwnershipStatusChanged(args.isPendingOwnershipRequest, args.community.id)
@ -226,6 +230,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
setActive = true setActive = true
) )
@ -248,6 +253,7 @@ proc init*(self: Controller) =
self.tokenService, self.tokenService,
self.communityTokensService, self.communityTokensService,
self.sharedUrlsService, self.sharedUrlsService,
self.networksService,
setActive = false setActive = false
) )

View File

@ -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/service as community_tokens_service
import app_service/service/community_tokens/community_collectible_owner import app_service/service/community_tokens/community_collectible_owner
import app_service/service/shared_urls/service as urls_service 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/dto as network_dto
from app_service/common/types import StatusType, ContractTransactionStatus, MembershipRequestState, Shard from app_service/common/types import StatusType, ContractTransactionStatus, MembershipRequestState, Shard
@ -98,6 +99,7 @@ method onChannelGroupsLoaded*(
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
) {.base.} = ) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -116,6 +118,7 @@ method onCommunityDataLoaded*(
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
){.base.} = ){.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -167,6 +170,7 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events:
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
setActive: bool = false, setActive: bool = false,
) {.base.} = ) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -683,6 +683,7 @@ method onChannelGroupsLoaded*[T](
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
) = ) =
self.chatsLoaded = true self.chatsLoaded = true
if not self.communityDataLoaded: if not self.communityDataLoaded:
@ -710,6 +711,7 @@ method onChannelGroupsLoaded*[T](
tokenService, tokenService,
communityTokensService, communityTokensService,
sharedUrlsService, sharedUrlsService,
networkService
) )
let channelGroupItem = self.createChannelGroupItem(channelGroup) let channelGroupItem = self.createChannelGroupItem(channelGroup)
self.view.model().addItem(channelGroupItem) self.view.model().addItem(channelGroupItem)
@ -744,6 +746,7 @@ method onCommunityDataLoaded*[T](
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
) = ) =
self.communityDataLoaded = true self.communityDataLoaded = true
if not self.chatsLoaded: if not self.chatsLoaded:
@ -764,6 +767,7 @@ method onCommunityDataLoaded*[T](
tokenService, tokenService,
communityTokensService, communityTokensService,
sharedUrlsService, sharedUrlsService,
networkService,
) )
method onChatsLoadingFailed*[T](self: Module[T]) = method onChatsLoadingFailed*[T](self: Module[T]) =
@ -1014,6 +1018,7 @@ method communityJoined*[T](
tokenService: token_service.Service, tokenService: token_service.Service,
communityTokensService: community_tokens_service.Service, communityTokensService: community_tokens_service.Service,
sharedUrlsService: urls_service.Service, sharedUrlsService: urls_service.Service,
networkService: network_service.Service,
setActive: bool = false, setActive: bool = false,
) = ) =
if self.channelGroupModules.contains(community.id): if self.channelGroupModules.contains(community.id):
@ -1039,6 +1044,7 @@ method communityJoined*[T](
tokenService, tokenService,
communityTokensService, communityTokensService,
sharedUrlsService, sharedUrlsService,
networkService
) )
let channelGroup = community.toChannelGroupDto() let channelGroup = community.toChannelGroupDto()
self.channelGroupModules[community.id].load() self.channelGroupModules[community.id].load()

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 3959948c4c5ab560ae528c2d331241f2cc94fed1 Subproject commit ba7faea027b1e87e6d53b0e487df2469cd6271f2