From 5f28d8b80968d45d35a41c650fa936b9b10666dc Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Thu, 2 Mar 2023 18:37:20 +0100 Subject: [PATCH] fix(@desktop/communities): Pass chainId to status-go call Fix #9725 --- src/app/boot/app_controller.nim | 2 +- .../modules/main/communities/minting/controller.nim | 4 ++-- .../modules/main/communities/minting/io_interface.nim | 2 +- src/app/modules/main/communities/minting/module.nim | 7 +++++-- src/app/modules/main/communities/minting/view.nim | 4 ++-- src/app_service/service/community_tokens/service.nim | 10 ++-------- src/backend/community_tokens.nim | 4 ++-- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index c7d58e1c78..c50c82e1dc 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -214,7 +214,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.settingsService, result.walletAccountService, result.transactionService, result.networkService, result.tokenService) result.tokensService = tokens_service.newService(statusFoundation.events, statusFoundation.threadpool, - result.networkService, result.transactionService) + result.transactionService) result.providerService = provider_service.newService(statusFoundation.events, statusFoundation.threadpool, result.ensService) # Modules diff --git a/src/app/modules/main/communities/minting/controller.nim b/src/app/modules/main/communities/minting/controller.nim index c3f730f805..f2e4210cac 100644 --- a/src/app/modules/main/communities/minting/controller.nim +++ b/src/app/modules/main/communities/minting/controller.nim @@ -34,8 +34,8 @@ proc init*(self: Controller) = return self.mintingModule.onUserAuthenticated(args.password) -proc mintCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters) = - self.communityTokensService.mintCollectibles(communityId, addressFrom, password, deploymentParams) +proc mintCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, chainId: int) = + self.communityTokensService.mintCollectibles(communityId, addressFrom, password, deploymentParams, chainId) proc authenticateUser*(self: Controller, keyUid = "") = let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER, keyUid: keyUid) diff --git a/src/app/modules/main/communities/minting/io_interface.nim b/src/app/modules/main/communities/minting/io_interface.nim index 172beb2929..075b677440 100644 --- a/src/app/modules/main/communities/minting/io_interface.nim +++ b/src/app/modules/main/communities/minting/io_interface.nim @@ -10,7 +10,7 @@ method load*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") method mintCollectible*(self: AccessInterface, communityId: string, address: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool, - selfDestruct: bool, network: string) {.base.} = + selfDestruct: bool, chainId: int) {.base.} = raise newException(ValueError, "No implementation available") method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} = diff --git a/src/app/modules/main/communities/minting/module.nim b/src/app/modules/main/communities/minting/module.nim index 819a9d910d..b99e1f3859 100644 --- a/src/app/modules/main/communities/minting/module.nim +++ b/src/app/modules/main/communities/minting/module.nim @@ -16,6 +16,7 @@ type viewVariant: QVariant tempAddressFrom: string tempCommunityId: string + tempChainId: int tempDeploymentParams: DeploymentParameters proc newMintingModule*( @@ -39,9 +40,10 @@ method load*(self: Module) = self.view.load() method mintCollectible*(self: Module, communityId: string, fromAddress: string, name: string, symbol: string, description: string, - supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, network: string) = + supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, chainId: int) = self.tempAddressFrom = fromAddress self.tempCommunityId = communityId + self.tempChainId = chainId self.tempDeploymentParams.name = name self.tempDeploymentParams.symbol = symbol self.tempDeploymentParams.description = description @@ -59,8 +61,9 @@ method onUserAuthenticated*(self: Module, password: string) = defer: self.tempAddressFrom = "" defer: self.tempDeploymentParams = DeploymentParameters() defer: self.tempCommunityId = "" + defer: self.tempChainId = -1 if password.len == 0: discard #TODO signalize somehow else: - self.controller.mintCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams) + self.controller.mintCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams, self.tempChainId) diff --git a/src/app/modules/main/communities/minting/view.nim b/src/app/modules/main/communities/minting/view.nim index 6f26a6a725..c5039cd874 100644 --- a/src/app/modules/main/communities/minting/view.nim +++ b/src/app/modules/main/communities/minting/view.nim @@ -18,8 +18,8 @@ QtObject: result.QObject.setup result.mintingModule = mintingModule - proc mintCollectible*(self: View, communityId: string, fromAddress: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, network: string) {.slot.} = - self.mintingModule.mintCollectible(communityId, fromAddress, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, network) + proc mintCollectible*(self: View, communityId: string, fromAddress: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, chainId: int) {.slot.} = + self.mintingModule.mintCollectible(communityId, fromAddress, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, chainId) diff --git a/src/app_service/service/community_tokens/service.nim b/src/app_service/service/community_tokens/service.nim index 15e77a079d..e0f0a994e2 100644 --- a/src/app_service/service/community_tokens/service.nim +++ b/src/app_service/service/community_tokens/service.nim @@ -3,7 +3,6 @@ import ../../../app/core/eventemitter import ../../../app/core/tasks/[qt, threadpool] import ../../../backend/community_tokens as tokens_backend -import ../network/service as network_service import ../transaction/service as transaction_service import ../eth/dto/transaction @@ -40,7 +39,6 @@ QtObject: Service* = ref object of QObject events: EventEmitter threadpool: ThreadPool - networkService: network_service.Service transactionService: transaction_service.Service proc delete*(self: Service) = @@ -49,14 +47,12 @@ QtObject: proc newService*( events: EventEmitter, threadpool: ThreadPool, - networkService: network_service.Service, transactionService: transaction_service.Service ): Service = result = Service() result.QObject.setup result.events = events result.threadpool = threadpool - result.networkService = networkService result.transactionService = transactionService proc init*(self: Service) = @@ -73,9 +69,8 @@ QtObject: let data = CommunityTokenDeployedStatusArgs(communityId: tokenDto.communityId, contractAddress: tokenDto.address, deployState: deployState) self.events.emit(SIGNAL_COMMUNITY_TOKEN_DEPLOY_STATUS, data) - proc mintCollectibles*(self: Service, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters) = + proc mintCollectibles*(self: Service, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, chainId: int) = try: - let chainId = self.networkService.getNetworkForCollectibles().chainId let txData = TransactionDataDto(source: parseAddress(addressFrom)) let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password) @@ -120,8 +115,7 @@ QtObject: proc getCommunityTokens*(self: Service, communityId: string): seq[CommunityTokenDto] = try: - let chainId = self.networkService.getNetworkForCollectibles().chainId - let response = tokens_backend.getCommunityTokens(communityId, chainId) + let response = tokens_backend.getCommunityTokens(communityId) return parseCommunityTokens(response) except RpcException: error "Error getting community tokens", message = getCurrentExceptionMsg() diff --git a/src/backend/community_tokens.nim b/src/backend/community_tokens.nim index 3154315518..ed81078afd 100644 --- a/src/backend/community_tokens.nim +++ b/src/backend/community_tokens.nim @@ -8,8 +8,8 @@ proc deployCollectibles*(chainId: int, deploymentParams: JsonNode, txData: JsonN let payload = %* [chainId, deploymentParams, txData, utils.hashPassword(password)] return core.callPrivateRPC("collectibles_deploy", payload) -proc getCommunityTokens*(communityId: string, chainId: int): RpcResponse[JsonNode] {.raises: [Exception].} = - let payload = %* [communityId, chainId] +proc getCommunityTokens*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [communityId] return core.callPrivateRPC("wakuext_getCommunityTokens", payload) proc addCommunityToken*(token: CommunityTokenDto): RpcResponse[JsonNode] {.raises: [Exception].} =