From 2e45889a9a4f619dddf9e71253119d681f82a257 Mon Sep 17 00:00:00 2001 From: Pascal Precht <445106+0x-r4bbit@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:11:34 +0100 Subject: [PATCH] refactor: TokenCriteriaType -> TokenType --- src/app/modules/main/chat_section/module.nim | 2 +- .../modules/shared_models/token_criteria_model.nim | 2 +- src/app_service/service/community/dto/community.nim | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 6df419914a..d2efbd2aab 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -1128,7 +1128,7 @@ method createOrEditCommunityTokenPermission*(self: Module, communityId: string, let viewAmount = tokenCriteria{"amount"}.getFloat var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto let contractAddresses = self.controller.getContractAddressesForToken(tokenCriteriaDto.symbol) - if contractAddresses.len == 0 and tokenCriteriaDto.`type` != TokenCriteriaType.ENS: + if contractAddresses.len == 0 and tokenCriteriaDto.`type` != community_dto.TokenType.ENS: if permissionId == "": self.onCommunityTokenPermissionCreationFailed(communityId) return diff --git a/src/app/modules/shared_models/token_criteria_model.nim b/src/app/modules/shared_models/token_criteria_model.nim index 334fd71ff4..5a0c6a3d74 100644 --- a/src/app/modules/shared_models/token_criteria_model.nim +++ b/src/app/modules/shared_models/token_criteria_model.nim @@ -58,7 +58,7 @@ QtObject: case enumRole: of ModelRole.Key: - if item.getType() == ord(TokenCriteriaType.ENS): + if item.getType() == ord(TokenType.ENS): result = newQVariant(item.getEnsPattern()) else: result = newQVariant(item.getSymbol()) diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index 4036883dba..ef187aaaf5 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -34,15 +34,15 @@ type TokenPermissionType* {.pure.}= enum BecomeAdmin = 1, BecomeMember = 2 -type TokenCriteriaType* {.pure.}= enum +type TokenType* {.pure.}= enum Unknown = 0, ERC20 = 1, ERC721 = 2, - ENS = 3 + ENS = 3 # ENS is also ERC721 but we want to distinguish without heuristics type TokenCriteriaDto* = object contractAddresses* {.serializedFieldName("contract_addresses").}: Table[int, string] - `type`* {.serializedFieldName("type").}: TokenCriteriaType + `type`* {.serializedFieldName("type").}: TokenType symbol* {.serializedFieldName("symbol").}: string name* {.serializedFieldName("name").}: string amount* {.serializedFieldName("amount").}: string @@ -171,8 +171,8 @@ proc toTokenCriteriaDto*(jsonObj: JsonNode): TokenCriteriaDto = var typeInt: int discard jsonObj.getProp("type", typeInt) - if (typeInt >= ord(low(TokenCriteriaType)) and typeInt <= ord(high(TokenCriteriaType))): - result.`type` = TokenCriteriaType(typeInt) + if (typeInt >= ord(low(TokenType)) and typeInt <= ord(high(TokenType))): + result.`type` = TokenType(typeInt) var contractAddressesObj: JsonNode if(jsonObj.getProp("contractAddresses", contractAddressesObj) and contractAddressesObj.kind == JObject): @@ -188,7 +188,7 @@ proc toTokenCriteriaDto*(jsonObj: JsonNode): TokenCriteriaDto = # When `toTokenCriteriaDto` is called with data coming from # the front-end, there's a key field we have to account for if jsonObj.hasKey("key"): - if result.`type` == TokenCriteriaType.ENS: + if result.`type` == TokenType.ENS: discard jsonObj.getProp("key", result.ensPattern) else: discard jsonObj.getProp("key", result.symbol)