Skip to content

Commit 5b2deb1

Browse files
committed
init
1 parent 2af6a6e commit 5b2deb1

File tree

74 files changed

+1147
-1412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1147
-1412
lines changed

src/app/modules/main/browser_section/current_account/controller.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ proc getEnabledChainIds*(self: Controller): seq[int] =
5050
proc getCurrentCurrency*(self: Controller): string =
5151
return self.walletAccountService.getCurrency()
5252

53-
proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
54-
return self.currencyService.getCurrencyFormat(symbol)
53+
proc getCurrencyFormat*(self: Controller, key: string): CurrencyFormatDto =
54+
return self.currencyService.getCurrencyFormat(key)
5555

5656
proc areTestNetworksEnabled*(self: Controller): bool =
5757
return self.walletAccountService.areTestNetworksEnabled()

src/app/modules/main/chat_section/controller.nim

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import ../../../core/signals/types
2121
import ../../../core/eventemitter
2222
import ../../../core/unique_event_emitter
2323

24-
import backend/collectibles_types
24+
# import backend/collectibles_types
2525

2626
type
2727
Controller* = ref object of RootObj
@@ -279,7 +279,7 @@ proc init*(self: Controller) =
279279
let args = CommunityTokenPermissionArgs(e)
280280
if (args.communityId == self.sectionId):
281281
self.delegate.onCommunityTokenPermissionUpdated(args.communityId, args.tokenPermission)
282-
282+
283283
self.events.on(SIGNAL_COMMUNITY_TOKEN_PERMISSION_DELETED) do(e: Args):
284284
let args = CommunityTokenPermissionArgs(e)
285285
if (args.communityId == self.sectionId):
@@ -725,37 +725,38 @@ proc createOrEditCommunityTokenPermission*(self: Controller, tokenPermission: Co
725725
proc deleteCommunityTokenPermission*(self: Controller, permissionId: string) =
726726
self.communityService.deleteCommunityTokenPermission(self.sectionId, permissionId)
727727

728-
proc allAccountsTokenBalance*(self: Controller, symbol: string): float64 =
729-
return self.walletAccountService.allAccountsTokenBalance(symbol)
730-
731-
proc getTokenDecimals*(self: Controller, symbol: string): int =
732-
let asset = self.tokenService.findTokenBySymbol(symbol)
733-
if asset != nil:
734-
return asset.decimals
735-
return 0
728+
## TODO: implement this - check usage of `getTokenDecimals` most likely will be removed cause token could be used there, and decimals could be taken from token
729+
# proc getTokenDecimals*(self: Controller, symbol: string): int =
730+
# let asset = self.tokenService.findTokenBySymbol(symbol)
731+
# if asset != nil:
732+
# return asset.decimals
733+
# return 0
736734

737735
# find addresses by tokenKey from UI
738736
# tokenKey can be: symbol for ERC20, or chain+address[+tokenId] for ERC721
739737
proc getContractAddressesForToken*(self: Controller, tokenKey: string): Table[int, string] =
740738
var contractAddresses = initTable[int, string]()
741-
let token = self.tokenService.findTokenBySymbol(tokenKey)
742-
if token != nil:
743-
for addrPerChain in token.addressPerChainId:
744-
# depending on areTestNetworksEnabled (in getNetworkByChainId), contractAddresses will
745-
# contain mainnets or testnets only
746-
let network = self.networkService.getNetworkByChainId(addrPerChain.chainId)
747-
if network == nil:
748-
continue
749-
contractAddresses[addrPerChain.chainId] = addrPerChain.address
750-
let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), tokenKey)
751-
if communityToken.address != "":
752-
contractAddresses[communityToken.chainId] = communityToken.address
753-
if contractAddresses.len == 0:
754-
try:
755-
let chainAndAddress = toContractID(tokenKey)
756-
contractAddresses[chainAndAddress.chainID] = chainAndAddress.address
757-
except Exception:
758-
discard
739+
740+
## TODO: implement this - check usage of `getContractAddressesForToken` and align implementation
741+
742+
# let token = self.tokenService.findTokenBySymbol(tokenKey)
743+
# if token != nil:
744+
# for addrPerChain in token.addressPerChainId:
745+
# # depending on areTestNetworksEnabled (in getNetworkByChainId), contractAddresses will
746+
# # contain mainnets or testnets only
747+
# let network = self.networkService.getNetworkByChainId(addrPerChain.chainId)
748+
# if network == nil:
749+
# continue
750+
# contractAddresses[addrPerChain.chainId] = addrPerChain.address
751+
# let communityToken = self.communityService.getCommunityTokenBySymbol(self.getMySectionId(), tokenKey)
752+
# if communityToken.address != "":
753+
# contractAddresses[communityToken.chainId] = communityToken.address
754+
# if contractAddresses.len == 0:
755+
# try:
756+
# let chainAndAddress = toContractID(tokenKey)
757+
# contractAddresses[chainAndAddress.chainID] = chainAndAddress.address
758+
# except Exception:
759+
# discard
759760
return contractAddresses
760761

761762
proc getCommunityTokenList*(self: Controller): seq[CommunityTokenDto] =

src/app/modules/main/chat_section/module.nim

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ method onChatsLoaded*(
369369
sharedUrlsService: shared_urls_service.Service,
370370
) =
371371
self.chatsLoaded = true
372-
372+
373373
self.buildChatSectionUI(community, chats, events, settingsService, nodeConfigurationService,
374374
contactService, chatService, communityService, messageService, mailserversService, sharedUrlsService)
375375

@@ -451,7 +451,7 @@ method activeItemSet*(self: Module, itemId: string) =
451451
# Should never be here
452452
error "chat-view unexisting item id: ", itemId, methodName="activeItemSet"
453453
return
454-
454+
455455
if not self.chatContentModules[itemId].isLoaded:
456456
self.chatContentModules[itemId].load(chat_item)
457457

@@ -834,7 +834,7 @@ method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
834834
let activeChatId = self.controller.getActiveChatId()
835835
if chatId == activeChatId:
836836
self.setFirstChannelAsActive()
837-
837+
838838
self.updateParentBadgeNotifications()
839839

840840
proc refreshHiddenBecauseNotPermittedState(self: Module) =
@@ -1487,8 +1487,9 @@ method createOrEditCommunityTokenPermission*(self: Module, permissionId: string,
14871487

14881488
let tokenKey = tokenCriteria{"key"}.getStr()
14891489
var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto
1490-
if tokenCriteriaDto.`type` == TokenType.ERC20:
1491-
tokenCriteriaDto.decimals = self.controller.getTokenDecimals(tokenKey)
1490+
# if tokenCriteriaDto.`type` == TokenType.ERC20:
1491+
## TODO: implement this - figure out token usage here
1492+
# tokenCriteriaDto.decimals = self.controller.getTokenDecimals(tokenKey)
14921493

14931494
let contractAddresses = self.controller.getContractAddressesForToken(tokenKey)
14941495
if contractAddresses.len == 0 and tokenCriteriaDto.`type` != TokenType.ENS:
@@ -1536,7 +1537,7 @@ method setChannelsPermissionsCheckOngoing*(self: Module, value: bool) =
15361537
for id, chat_item in self.view.chatsModel().items():
15371538
if self.view.chatsModel().getItemPermissionsRequired(chat_item.id):
15381539
self.view.chatsModel().updatePermissionsCheckOngoing(chat_item.id, true)
1539-
1540+
15401541
method onWaitingOnNewCommunityOwnerToConfirmRequestToRejoin*(self: Module) =
15411542
self.view.setWaitingOnNewCommunityOwnerToConfirmRequestToRejoin(true)
15421543

src/app/modules/main/communities/controller.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,6 @@ proc getAllCommunityTokens*(self: Controller): seq[CommunityTokenDto] =
354354
proc getNetworkByChainId*(self:Controller, chainId: int): NetworkItem =
355355
self.networksService.getNetworkByChainId(chainId)
356356

357-
proc getTokenBySymbolList*(self: Controller): seq[TokenBySymbolItem] =
358-
return self.tokenService.getTokenBySymbolList()
359-
360357
proc shareCommunityUrlWithChatKey*(self: Controller, communityId: string): string =
361358
return self.communityService.shareCommunityUrlWithChatKey(communityId)
362359

@@ -450,7 +447,7 @@ proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataTo
450447
var finalDataToSign = status_general.hashMessageForSigning(dataToSign)
451448
if finalDataToSign.startsWith("0x"):
452449
finalDataToSign = finalDataToSign[2..^1]
453-
450+
454451
if pin.len == 0:
455452
let data = SharedKeycarModuleSigningArgs(uniqueIdentifier: UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER,
456453
keyUid: keyUid,

src/app/modules/main/communities/module.nim

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -573,32 +573,32 @@ proc buildTokensAndCollectiblesFromAllCommunities(self: Module) =
573573
proc buildTokensAndCollectiblesFromWallet(self: Module) =
574574
var tokenListItems: seq[TokenListItem]
575575

576-
# Common ERC20 tokens
577-
let allNetworks = self.controller.getCurrentNetworksChainIds()
578-
let erc20Tokens = self.controller.getTokenBySymbolList().filter(t => (block:
579-
let filteredChains = t.addressPerChainId.filter(apC => allNetworks.contains(apc.chainId))
580-
return filteredChains.len != 0
581-
))
582-
for token in erc20Tokens:
583-
let communityTokens = self.controller.getCommunityTokens(token.communityId)
584-
var privilegesLevel = PrivilegesLevel.Community.int
585-
for communityToken in communityTokens:
586-
if communityToken.symbol == token.symbol:
587-
privilegesLevel = communityToken.privilegesLevel.int
588-
break
589-
590-
let tokenListItem = initTokenListItem(
591-
key = token.symbol,
592-
name = token.name,
593-
symbol = token.symbol,
594-
color = "",
595-
communityId = token.communityId,
596-
image = "",
597-
category = ord(TokenListItemCategory.General),
598-
decimals = token.decimals,
599-
privilegesLevel = privilegesLevel
600-
)
601-
tokenListItems.add(tokenListItem)
576+
# # Common ERC20 tokens
577+
# let allNetworks = self.controller.getCurrentNetworksChainIds()
578+
# let erc20Tokens = self.controller.getTokenBySymbolList().filter(t => (block:
579+
# let filteredChains = t.addressPerChainId.filter(apC => allNetworks.contains(apc.chainId))
580+
# return filteredChains.len != 0
581+
# ))
582+
# for token in erc20Tokens:
583+
# let communityTokens = self.controller.getCommunityTokens(token.communityId)
584+
# var privilegesLevel = PrivilegesLevel.Community.int
585+
# for communityToken in communityTokens:
586+
# if communityToken.symbol == token.symbol:
587+
# privilegesLevel = communityToken.privilegesLevel.int
588+
# break
589+
590+
# let tokenListItem = initTokenListItem(
591+
# key = token.symbol,
592+
# name = token.name,
593+
# symbol = token.symbol,
594+
# color = "",
595+
# communityId = token.communityId,
596+
# image = "",
597+
# category = ord(TokenListItemCategory.General),
598+
# decimals = token.decimals,
599+
# privilegesLevel = privilegesLevel
600+
# )
601+
# tokenListItems.add(tokenListItem)
602602

603603
self.view.tokenListModel.setWalletTokenItems(tokenListItems)
604604

src/app/modules/main/profile_section/ens_usernames/controller.nim

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,8 @@ proc getWalletDefaultAddress*(self: Controller): string =
115115
proc getCurrentCurrency*(self: Controller): string =
116116
return self.settingsService.getCurrency()
117117

118-
proc getPriceBySymbol*(self: Controller, crypto: string): float64 =
119-
return self.tokenService.getPriceBySymbol(crypto)
120-
121-
proc getStatusTokenKey*(self: Controller): string =
122-
return self.tokenService.getStatusTokenKey()
118+
proc getPriceForToken*(self: Controller, tokenKey: string): float64 =
119+
return self.tokenService.getPriceForToken(tokenKey)
123120

124121
proc ensnameResolverAddress*(self: Controller, ensUsername: string): string =
125122
return self.ensService.ensnameResolverAddress(ensUsername)

src/app/modules/main/profile_section/ens_usernames/io_interface.nim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ method getCryptoValue*(self: AccessInterface, fiatAmount: string, cryptoSymbol:
6767
{.base.} =
6868
raise newException(ValueError, "No implementation available")
6969

70-
method getStatusTokenKey*(self: AccessInterface): string {.base.} =
71-
raise newException(ValueError, "No implementation available")
72-
7370
method setPrefferedEnsUsername*(self: AccessInterface, ensUsername: string) {.base.} =
7471
raise newException(ValueError, "No implementation available")
7572

src/app/modules/main/profile_section/ens_usernames/module.nim

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,37 +171,34 @@ method getWalletDefaultAddress*(self: Module): string =
171171
method getCurrentCurrency*(self: Module): string =
172172
return self.controller.getCurrentCurrency()
173173

174-
method getFiatValue*(self: Module, cryptoBalance: string, cryptoSymbol: string): string =
174+
method getFiatValue*(self: Module, cryptoBalance: string, tokenKey: string): string =
175175
var floatCryptoBalance: float = 0
176176
try:
177177
floatCryptoBalance = parseFloat(cryptoBalance)
178178
except ValueError:
179179
return "0.00"
180180

181-
if (cryptoBalance == "" or cryptoSymbol == ""):
181+
if (cryptoBalance == "" or tokenKey == ""):
182182
return "0.00"
183183

184-
let price = self.controller.getPriceBySymbol(cryptoSymbol)
184+
let price = self.controller.getPriceForToken(tokenKey)
185185
let value = floatCryptoBalance * price
186186
return fmt"{value}"
187187

188-
method getCryptoValue*(self: Module, fiatAmount: string, cryptoSymbol: string): string =
188+
method getCryptoValue*(self: Module, fiatAmount: string, tokenKey: string): string =
189189
var fiatAmountBalance: float = 0
190190
try:
191191
fiatAmountBalance = parseFloat(fiatAmount)
192192
except ValueError:
193193
return "0.00"
194194

195-
if (fiatAmount == "" or cryptoSymbol == ""):
195+
if (fiatAmount == "" or tokenKey == ""):
196196
return "0.00"
197197

198-
let price = self.controller.getPriceBySymbol(cryptoSymbol)
198+
let price = self.controller.getPriceForToken(tokenKey)
199199
let value = fiatAmountBalance / price
200200
return fmt"{value}"
201201

202-
method getStatusTokenKey*(self: Module): string =
203-
return self.controller.getStatusTokenKey()
204-
205202
method setPrefferedEnsUsername*(self: Module, ensUsername: string) =
206203
self.controller.setPreferredName(ensUsername)
207204

src/app/modules/main/profile_section/ens_usernames/view.nim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import nimqml
22
import io_interface
33
import model
4+
5+
import app_service/common/wallet_constants
6+
import app_service/service/token/dto/token
47
from app_service/service/ens/utils import ENS_REGISTRY
58

69
QtObject:
@@ -97,8 +100,12 @@ QtObject:
97100
proc getCryptoValue*(self: View, fiatAmount: string, cryptoSymbol: string): string {.slot.} =
98101
return self.delegate.getCryptoValue(fiatAmount, cryptoSymbol)
99102

100-
proc getStatusTokenKey*(self: View): string {.slot.} =
101-
return self.delegate.getStatusTokenKey()
103+
proc getStatusTokenKeyForChainId*(self: View, chainId: int): string {.slot.} =
104+
let token = TokenDto(
105+
chainId: chainId,
106+
address: wallet_constants.statusTokenAddressForChainId(chainId)
107+
)
108+
return token.key()
102109

103110
proc setPrefferedEnsUsername*(self: View, ensUsername: string) {.slot.} =
104111
self.delegate.setPrefferedEnsUsername(ensUsername)

src/app/modules/main/profile_section/profile/controller.nim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,3 @@ proc getProfileShowcaseEntriesLimit*(self: Controller): int =
9696

9797
proc requestCommunityInfo*(self: Controller, communityId: string, shard: Shard) =
9898
self.communityService.requestCommunityInfo(communityId, shard)
99-
100-
proc getTokenBySymbolList*(self: Controller): var seq[TokenBySymbolItem] =
101-
self.tokenService.getTokenBySymbolList()

0 commit comments

Comments
 (0)