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
nim_status_client.log
*.csv
.flatpak-builder
# 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/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 != "":

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/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

View File

@ -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
)

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/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")

View File

@ -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()

2
vendor/status-go vendored

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