fix(Communities): show community tokens in token section (#11970)
Close #11843
This commit is contained in:
parent
43f49c0b2d
commit
3463d7a01f
|
@ -49,7 +49,7 @@ type
|
|||
method setCommunityTags*(self: Module, communityTags: string)
|
||||
method setAllCommunities*(self: Module, communities: seq[CommunityDto])
|
||||
method setCuratedCommunities*(self: Module, curatedCommunities: seq[CommunityDto])
|
||||
proc buildTokenList(self: Module)
|
||||
proc buildTokensAndCollectibles(self: Module)
|
||||
|
||||
proc newModule*(
|
||||
delegate: delegate_interface.AccessInterface,
|
||||
|
@ -103,7 +103,7 @@ method viewDidLoad*(self: Module) =
|
|||
method communityDataLoaded*(self: Module) =
|
||||
self.setCommunityTags(self.controller.getCommunityTags())
|
||||
self.setAllCommunities(self.controller.getAllCommunities())
|
||||
self.buildTokenList()
|
||||
self.buildTokensAndCollectibles()
|
||||
|
||||
method onActivated*(self: Module) =
|
||||
self.controller.asyncLoadCuratedCommunities()
|
||||
|
@ -422,25 +422,11 @@ proc createCommunityTokenItem(self: Module, token: CommunityTokensMetadataDto, c
|
|||
infiniteSupply,
|
||||
)
|
||||
|
||||
proc buildTokenList(self: Module) =
|
||||
proc buildTokensAndCollectibles(self: Module) =
|
||||
var tokenListItems: seq[TokenListItem]
|
||||
var collectiblesListItems: seq[TokenListItem]
|
||||
|
||||
let communities = self.controller.getAllCommunities()
|
||||
let erc20Tokens = self.controller.getTokenList()
|
||||
|
||||
for token in erc20Tokens:
|
||||
let tokenListItem = initTokenListItem(
|
||||
key = token.symbol,
|
||||
name = token.name,
|
||||
symbol = token.symbol,
|
||||
color = token.color,
|
||||
image = "",
|
||||
category = ord(TokenListItemCategory.General),
|
||||
)
|
||||
|
||||
tokenListItems.add(tokenListItem)
|
||||
|
||||
for community in communities:
|
||||
let communityTokens = self.controller.getCommunityTokens(community.id)
|
||||
for tokenMetadata in community.communityTokensMetadata:
|
||||
|
@ -452,21 +438,42 @@ proc buildTokenList(self: Module) =
|
|||
supply = communityToken.supply.toString(10)
|
||||
infiniteSupply = communityToken.infiniteSupply
|
||||
break
|
||||
collectiblesListItems.add(self.createCommunityTokenItem(
|
||||
|
||||
var communityTokenItem = self.createCommunityTokenItem(
|
||||
tokenMetadata,
|
||||
community.id,
|
||||
supply,
|
||||
infiniteSupply,
|
||||
))
|
||||
)
|
||||
|
||||
if tokenMetadata.tokenType == community_dto.TokenType.ERC20:
|
||||
# Community ERC20 tokens
|
||||
tokenListItems.add(communityTokenItem, )
|
||||
else:
|
||||
# Community collectibles (ERC721 and others)
|
||||
collectiblesListItems.add(communityTokenItem)
|
||||
|
||||
# Common ERC20 tokens
|
||||
let erc20Tokens = self.controller.getTokenList()
|
||||
for token in erc20Tokens:
|
||||
let tokenListItem = initTokenListItem(
|
||||
key = token.symbol,
|
||||
name = token.name,
|
||||
symbol = token.symbol,
|
||||
color = token.color,
|
||||
image = "",
|
||||
category = ord(TokenListItemCategory.General),
|
||||
)
|
||||
tokenListItems.add(tokenListItem)
|
||||
|
||||
self.view.setTokenListItems(tokenListItems)
|
||||
self.view.setCollectiblesListItems(collectiblesListItems)
|
||||
|
||||
method onWalletAccountTokensRebuilt*(self: Module) =
|
||||
self.buildTokenList()
|
||||
self.buildTokensAndCollectibles()
|
||||
|
||||
method onOwnedCollectiblesUpdated*(self: Module) =
|
||||
self.buildTokenList()
|
||||
self.buildTokensAndCollectibles()
|
||||
|
||||
method onCommunityTokenMetadataAdded*(self: Module, communityId: string, tokenMetadata: CommunityTokensMetadataDto) =
|
||||
let communityTokens = self.controller.getCommunityTokens(communityId)
|
||||
|
|
Loading…
Reference in New Issue