refactor: TokenCriteriaType -> TokenType
This commit is contained in:
parent
467539446d
commit
2e45889a9a
|
@ -1128,7 +1128,7 @@ 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 contractAddresses = self.controller.getContractAddressesForToken(tokenCriteriaDto.symbol)
|
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 == "":
|
if permissionId == "":
|
||||||
self.onCommunityTokenPermissionCreationFailed(communityId)
|
self.onCommunityTokenPermissionCreationFailed(communityId)
|
||||||
return
|
return
|
||||||
|
|
|
@ -58,7 +58,7 @@ QtObject:
|
||||||
case enumRole:
|
case enumRole:
|
||||||
of ModelRole.Key:
|
of ModelRole.Key:
|
||||||
|
|
||||||
if item.getType() == ord(TokenCriteriaType.ENS):
|
if item.getType() == ord(TokenType.ENS):
|
||||||
result = newQVariant(item.getEnsPattern())
|
result = newQVariant(item.getEnsPattern())
|
||||||
else:
|
else:
|
||||||
result = newQVariant(item.getSymbol())
|
result = newQVariant(item.getSymbol())
|
||||||
|
|
|
@ -34,15 +34,15 @@ type TokenPermissionType* {.pure.}= enum
|
||||||
BecomeAdmin = 1,
|
BecomeAdmin = 1,
|
||||||
BecomeMember = 2
|
BecomeMember = 2
|
||||||
|
|
||||||
type TokenCriteriaType* {.pure.}= enum
|
type TokenType* {.pure.}= enum
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
ERC20 = 1,
|
ERC20 = 1,
|
||||||
ERC721 = 2,
|
ERC721 = 2,
|
||||||
ENS = 3
|
ENS = 3 # ENS is also ERC721 but we want to distinguish without heuristics
|
||||||
|
|
||||||
type TokenCriteriaDto* = object
|
type TokenCriteriaDto* = object
|
||||||
contractAddresses* {.serializedFieldName("contract_addresses").}: Table[int, string]
|
contractAddresses* {.serializedFieldName("contract_addresses").}: Table[int, string]
|
||||||
`type`* {.serializedFieldName("type").}: TokenCriteriaType
|
`type`* {.serializedFieldName("type").}: TokenType
|
||||||
symbol* {.serializedFieldName("symbol").}: string
|
symbol* {.serializedFieldName("symbol").}: string
|
||||||
name* {.serializedFieldName("name").}: string
|
name* {.serializedFieldName("name").}: string
|
||||||
amount* {.serializedFieldName("amount").}: string
|
amount* {.serializedFieldName("amount").}: string
|
||||||
|
@ -171,8 +171,8 @@ proc toTokenCriteriaDto*(jsonObj: JsonNode): TokenCriteriaDto =
|
||||||
|
|
||||||
var typeInt: int
|
var typeInt: int
|
||||||
discard jsonObj.getProp("type", typeInt)
|
discard jsonObj.getProp("type", typeInt)
|
||||||
if (typeInt >= ord(low(TokenCriteriaType)) and typeInt <= ord(high(TokenCriteriaType))):
|
if (typeInt >= ord(low(TokenType)) and typeInt <= ord(high(TokenType))):
|
||||||
result.`type` = TokenCriteriaType(typeInt)
|
result.`type` = TokenType(typeInt)
|
||||||
|
|
||||||
var contractAddressesObj: JsonNode
|
var contractAddressesObj: JsonNode
|
||||||
if(jsonObj.getProp("contractAddresses", contractAddressesObj) and contractAddressesObj.kind == JObject):
|
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
|
# When `toTokenCriteriaDto` is called with data coming from
|
||||||
# the front-end, there's a key field we have to account for
|
# the front-end, there's a key field we have to account for
|
||||||
if jsonObj.hasKey("key"):
|
if jsonObj.hasKey("key"):
|
||||||
if result.`type` == TokenCriteriaType.ENS:
|
if result.`type` == TokenType.ENS:
|
||||||
discard jsonObj.getProp("key", result.ensPattern)
|
discard jsonObj.getProp("key", result.ensPattern)
|
||||||
else:
|
else:
|
||||||
discard jsonObj.getProp("key", result.symbol)
|
discard jsonObj.getProp("key", result.symbol)
|
||||||
|
|
Loading…
Reference in New Issue