fix(@desktop/wallet): Fix issues in adding minted collectible as permision in a community

This commit is contained in:
Khushboo Mehta 2024-02-13 14:23:58 +01:00 committed by Khushboo-dev-cpp
parent a55998cf8a
commit d970e7c3f2
2 changed files with 24 additions and 14 deletions

View File

@ -678,8 +678,22 @@ proc deleteCommunityTokenPermission*(self: Controller, communityId: string, perm
proc allAccountsTokenBalance*(self: Controller, symbol: string): float64 = proc allAccountsTokenBalance*(self: Controller, symbol: string): float64 =
return self.walletAccountService.allAccountsTokenBalance(symbol) return self.walletAccountService.allAccountsTokenBalance(symbol)
proc findTokenBySymbol*(self: Controller, symbol: string): TokenBySymbolItem = proc getTokenDecimals*(self: Controller, symbol: string): int =
return self.tokenService.findTokenBySymbol(symbol) let asset = self.tokenService.findTokenBySymbol(symbol)
if asset != nil:
return asset.decimals
return 0
proc getContractAddressesForToken*(self: Controller, symbol: string): Table[int, string] =
var contractAddresses = initTable[int, string]()
let token = self.tokenService.findTokenBySymbol(symbol)
if token != nil:
for addrPerChain in token.addressPerChainId:
contractAddresses[addrPerChain.chainId] = addrPerChain.address
let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), symbol)
if communityToken.address != "":
contractAddresses[communityToken.chainId] = communityToken.address
return contractAddresses
proc getCommunityTokenList*(self: Controller): seq[CommunityTokenDto] = proc getCommunityTokenList*(self: Controller): seq[CommunityTokenDto] =
return self.communityTokensService.getCommunityTokens(self.getMySectionId()) return self.communityTokensService.getCommunityTokens(self.getMySectionId())

View File

@ -1309,22 +1309,18 @@ method createOrEditCommunityTokenPermission*(self: Module, communityId: string,
let viewAmount = tokenCriteria{"amount"}.getFloat let viewAmount = tokenCriteria{"amount"}.getFloat
var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto
let token = self.controller.findTokenBySymbol(tokenCriteriaDto.symbol) if tokenCriteriaDto.`type` == TokenType.ERC20:
if token != nil: tokenCriteriaDto.decimals = self.controller.getTokenDecimals(tokenCriteriaDto.symbol)
if tokenCriteriaDto.`type` == TokenType.ERC20:
tokenCriteriaDto.decimals = token.decimals
if token.addressPerChainId.len == 0 and tokenCriteriaDto.`type` != TokenType.ENS: let contractAddresses = self.controller.getContractAddressesForToken(tokenCriteriaDto.symbol)
if permissionId == "": if contractAddresses.len == 0 and tokenCriteriaDto.`type` != TokenType.ENS:
self.onCommunityTokenPermissionCreationFailed(communityId) if permissionId == "":
return self.onCommunityTokenPermissionCreationFailed(communityId)
self.onCommunityTokenPermissionUpdateFailed(communityId)
return return
self.onCommunityTokenPermissionUpdateFailed(communityId)
return
tokenCriteriaDto.amount = viewAmount.formatBiggestFloat(ffDecimal) tokenCriteriaDto.amount = viewAmount.formatBiggestFloat(ffDecimal)
var contractAddresses = initTable[int, string]()
for addrPerChain in token.addressPerChainId:
contractAddresses[addrPerChain.chainId] = addrPerChain.address
tokenCriteriaDto.contractAddresses = contractAddresses tokenCriteriaDto.contractAddresses = contractAddresses
tokenPermission.tokenCriteria.add(tokenCriteriaDto) tokenPermission.tokenCriteria.add(tokenCriteriaDto)