fix(@desktop/communities): Pass chainId to status-go call

Fix #9725
This commit is contained in:
Michal Iskierko 2023-03-02 18:37:20 +01:00 committed by Michał Iskierko
parent 40a157a5af
commit 5f28d8b809
7 changed files with 15 additions and 18 deletions

View File

@ -214,7 +214,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.settingsService, result.walletAccountService, result.transactionService, result.settingsService, result.walletAccountService, result.transactionService,
result.networkService, result.tokenService) result.networkService, result.tokenService)
result.tokensService = tokens_service.newService(statusFoundation.events, statusFoundation.threadpool, 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) result.providerService = provider_service.newService(statusFoundation.events, statusFoundation.threadpool, result.ensService)
# Modules # Modules

View File

@ -34,8 +34,8 @@ proc init*(self: Controller) =
return return
self.mintingModule.onUserAuthenticated(args.password) self.mintingModule.onUserAuthenticated(args.password)
proc mintCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters) = proc mintCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, chainId: int) =
self.communityTokensService.mintCollectibles(communityId, addressFrom, password, deploymentParams) self.communityTokensService.mintCollectibles(communityId, addressFrom, password, deploymentParams, chainId)
proc authenticateUser*(self: Controller, keyUid = "") = proc authenticateUser*(self: Controller, keyUid = "") =
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER, keyUid: keyUid) let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER, keyUid: keyUid)

View File

@ -10,7 +10,7 @@ method load*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") 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, 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") raise newException(ValueError, "No implementation available")
method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} = method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =

View File

@ -16,6 +16,7 @@ type
viewVariant: QVariant viewVariant: QVariant
tempAddressFrom: string tempAddressFrom: string
tempCommunityId: string tempCommunityId: string
tempChainId: int
tempDeploymentParams: DeploymentParameters tempDeploymentParams: DeploymentParameters
proc newMintingModule*( proc newMintingModule*(
@ -39,9 +40,10 @@ method load*(self: Module) =
self.view.load() self.view.load()
method mintCollectible*(self: Module, communityId: string, fromAddress: string, name: string, symbol: string, description: string, 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.tempAddressFrom = fromAddress
self.tempCommunityId = communityId self.tempCommunityId = communityId
self.tempChainId = chainId
self.tempDeploymentParams.name = name self.tempDeploymentParams.name = name
self.tempDeploymentParams.symbol = symbol self.tempDeploymentParams.symbol = symbol
self.tempDeploymentParams.description = description self.tempDeploymentParams.description = description
@ -59,8 +61,9 @@ method onUserAuthenticated*(self: Module, password: string) =
defer: self.tempAddressFrom = "" defer: self.tempAddressFrom = ""
defer: self.tempDeploymentParams = DeploymentParameters() defer: self.tempDeploymentParams = DeploymentParameters()
defer: self.tempCommunityId = "" defer: self.tempCommunityId = ""
defer: self.tempChainId = -1
if password.len == 0: if password.len == 0:
discard discard
#TODO signalize somehow #TODO signalize somehow
else: else:
self.controller.mintCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams) self.controller.mintCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams, self.tempChainId)

View File

@ -18,8 +18,8 @@ QtObject:
result.QObject.setup result.QObject.setup
result.mintingModule = mintingModule 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.} = 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, network) self.mintingModule.mintCollectible(communityId, fromAddress, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, chainId)

View File

@ -3,7 +3,6 @@ import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool] import ../../../app/core/tasks/[qt, threadpool]
import ../../../backend/community_tokens as tokens_backend import ../../../backend/community_tokens as tokens_backend
import ../network/service as network_service
import ../transaction/service as transaction_service import ../transaction/service as transaction_service
import ../eth/dto/transaction import ../eth/dto/transaction
@ -40,7 +39,6 @@ QtObject:
Service* = ref object of QObject Service* = ref object of QObject
events: EventEmitter events: EventEmitter
threadpool: ThreadPool threadpool: ThreadPool
networkService: network_service.Service
transactionService: transaction_service.Service transactionService: transaction_service.Service
proc delete*(self: Service) = proc delete*(self: Service) =
@ -49,14 +47,12 @@ QtObject:
proc newService*( proc newService*(
events: EventEmitter, events: EventEmitter,
threadpool: ThreadPool, threadpool: ThreadPool,
networkService: network_service.Service,
transactionService: transaction_service.Service transactionService: transaction_service.Service
): Service = ): Service =
result = Service() result = Service()
result.QObject.setup result.QObject.setup
result.events = events result.events = events
result.threadpool = threadpool result.threadpool = threadpool
result.networkService = networkService
result.transactionService = transactionService result.transactionService = transactionService
proc init*(self: Service) = proc init*(self: Service) =
@ -73,9 +69,8 @@ QtObject:
let data = CommunityTokenDeployedStatusArgs(communityId: tokenDto.communityId, contractAddress: tokenDto.address, deployState: deployState) let data = CommunityTokenDeployedStatusArgs(communityId: tokenDto.communityId, contractAddress: tokenDto.address, deployState: deployState)
self.events.emit(SIGNAL_COMMUNITY_TOKEN_DEPLOY_STATUS, data) 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: try:
let chainId = self.networkService.getNetworkForCollectibles().chainId
let txData = TransactionDataDto(source: parseAddress(addressFrom)) let txData = TransactionDataDto(source: parseAddress(addressFrom))
let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password) let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password)
@ -120,8 +115,7 @@ QtObject:
proc getCommunityTokens*(self: Service, communityId: string): seq[CommunityTokenDto] = proc getCommunityTokens*(self: Service, communityId: string): seq[CommunityTokenDto] =
try: try:
let chainId = self.networkService.getNetworkForCollectibles().chainId let response = tokens_backend.getCommunityTokens(communityId)
let response = tokens_backend.getCommunityTokens(communityId, chainId)
return parseCommunityTokens(response) return parseCommunityTokens(response)
except RpcException: except RpcException:
error "Error getting community tokens", message = getCurrentExceptionMsg() error "Error getting community tokens", message = getCurrentExceptionMsg()

View File

@ -8,8 +8,8 @@ proc deployCollectibles*(chainId: int, deploymentParams: JsonNode, txData: JsonN
let payload = %* [chainId, deploymentParams, txData, utils.hashPassword(password)] let payload = %* [chainId, deploymentParams, txData, utils.hashPassword(password)]
return core.callPrivateRPC("collectibles_deploy", payload) return core.callPrivateRPC("collectibles_deploy", payload)
proc getCommunityTokens*(communityId: string, chainId: int): RpcResponse[JsonNode] {.raises: [Exception].} = proc getCommunityTokens*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [communityId, chainId] let payload = %* [communityId]
return core.callPrivateRPC("wakuext_getCommunityTokens", payload) return core.callPrivateRPC("wakuext_getCommunityTokens", payload)
proc addCommunityToken*(token: CommunityTokenDto): RpcResponse[JsonNode] {.raises: [Exception].} = proc addCommunityToken*(token: CommunityTokenDto): RpcResponse[JsonNode] {.raises: [Exception].} =