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 =
return self.walletAccountService.allAccountsTokenBalance(symbol)
proc findTokenBySymbol*(self: Controller, symbol: string): TokenBySymbolItem =
return self.tokenService.findTokenBySymbol(symbol)
proc getTokenDecimals*(self: Controller, symbol: string): int =
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] =
return self.communityTokensService.getCommunityTokens(self.getMySectionId())

View File

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