Skip to content

Commit 475b5a4

Browse files
committed
init
1 parent 27a26e9 commit 475b5a4

File tree

152 files changed

+2443
-2418
lines changed

Some content is hidden

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

152 files changed

+2443
-2418
lines changed

src/app/core/signals/remote_signals/wallet.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNo
109109
result.errorCode = errorResponseJsonNode["code"].getStr
110110
result.updatedPrices = initTable[string, float64]()
111111
if event.contains("UpdatedPrices"):
112-
for tokenSymbol, price in event["UpdatedPrices"].pairs():
113-
result.updatedPrices[tokenSymbol] = price.getFloat
112+
for tokenKey, price in event["UpdatedPrices"].pairs():
113+
result.updatedPrices[tokenKey] = price.getFloat
114114
except Exception as e:
115115
error "Error parsing best route: ", err=e.msg
116116
return

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/chat_content/input_area/view.nim

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import nimqml, sets
22
import ./io_interface
33
import ./preserved_properties
44
import ./urls_model
5-
import ../../../../../../app/modules/shared_models/link_preview_model as link_preview_model
6-
import ../../../../../../app/modules/shared_models/payment_request_model as payment_request_model
7-
import ../../../../../../app/modules/shared_models/default_emoji_reactions_model as default_emoji_reactions_model
5+
import app/modules/shared_models/link_preview_model as link_preview_model
6+
import app/modules/shared_models/payment_request_model as payment_request_model
7+
import app/modules/shared_models/default_emoji_reactions_model as default_emoji_reactions_model
88

99
QtObject:
1010
type
@@ -89,7 +89,7 @@ QtObject:
8989
QtProperty[bool] askToEnableLinkPreview:
9090
read = getAskToEnableLinkPreview
9191
notify = askToEnableLinkPreviewChanged
92-
92+
9393
# Currently used to fetch link previews, but could be used elsewhere
9494
proc setText*(self: View, text: string) {.slot.} =
9595
self.delegate.setText(text, true)
@@ -100,7 +100,7 @@ QtObject:
100100
proc updateLinkPreviewsFromCache*(self: View, urls: seq[string]) =
101101
let linkPreviews = self.delegate.linkPreviewsFromCache(urls)
102102
self.linkPreviewModel.updateLinkPreviews(linkPreviews)
103-
103+
104104
for contactId in self.linkPreviewModel.getContactIds().items:
105105
let contact = self.delegate.getContactDetails(contactId)
106106
if contact.dto.displayName != "":
@@ -115,25 +115,25 @@ QtObject:
115115

116116
proc reloadLinkPreview(self: View, link: string) {.slot.} =
117117
self.delegate.loadLinkPreviews(@[link])
118-
118+
119119
proc loadLinkPreviews(self: View, links: seq[string]) =
120120
self.delegate.loadLinkPreviews(links)
121-
121+
122122
proc enableLinkPreview(self: View) {.slot.} =
123123
self.delegate.setLinkPreviewEnabled(true)
124-
124+
125125
proc disableLinkPreview(self: View) {.slot.} =
126126
self.delegate.setLinkPreviewEnabled(false)
127-
127+
128128
proc setLinkPreviewEnabledForCurrentMessage(self: View, enabled: bool) {.slot.} =
129129
self.delegate.setLinkPreviewEnabledForThisMessage(enabled)
130130
self.delegate.reloadUnfurlingPlan()
131131

132132
proc removeLinkPreviewData*(self: View, index: int) {.slot.} =
133133
self.linkPreviewModel.removePreviewData(index)
134134

135-
proc addPaymentRequest*(self: View, receiver: string, amount: string, symbol: string, chainId: int) {.slot.} =
136-
self.paymentRequestModel.addPaymentRequest(receiver, amount, symbol, chainId)
135+
proc addPaymentRequest*(self: View, receiver: string, amount: string, tokenKey: string, symbol: string) {.slot.} =
136+
self.paymentRequestModel.addPaymentRequest(receiver, amount, tokenKey, symbol)
137137

138138
proc removePaymentRequestPreviewData*(self: View, index: int) {.slot.} =
139139
self.paymentRequestModel.removeItemWithIndex(index)

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: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ method requestCancelDiscordChannelImport*(self: Module, discordChannelId: string
513513
self.controller.requestCancelDiscordChannelImport(discordChannelId)
514514

515515
proc createCommunityTokenItem(self: Module, token: CommunityTokensMetadataDto, communityId: string, supply: string,
516-
infiniteSupply: bool, privilegesLevel: int): TokenListItem =
516+
infiniteSupply: bool, privilegesLevel: int): token_list_item.TokenListItem =
517517
let communityTokenDecimals = if token.tokenType == TokenType.ERC20: 18 else: 0
518518
let key = if token.tokenType == TokenType.ERC721: token.getContractIdFromFirstAddress() else: token.symbol
519519
result = initTokenListItem(
@@ -531,7 +531,7 @@ proc createCommunityTokenItem(self: Module, token: CommunityTokensMetadataDto, c
531531
)
532532

533533
proc buildCommunityTokenItemFallback(self: Module, communityTokens: seq[CommunityTokenDto],
534-
token: CommunityTokensMetadataDto, communityId: string): TokenListItem =
534+
token: CommunityTokensMetadataDto, communityId: string): token_list_item.TokenListItem =
535535
# Set fallback supply to infinite in case we don't have it
536536
var supply = "1"
537537
var infiniteSupply = true
@@ -545,8 +545,8 @@ proc buildCommunityTokenItemFallback(self: Module, communityTokens: seq[Communit
545545
return self.createCommunityTokenItem(token, communityId, supply, infiniteSupply, privilegesLevel)
546546

547547
proc buildTokensAndCollectiblesFromCommunities(self: Module, communities: seq[CommunityDto]) =
548-
var tokenListItems: seq[TokenListItem]
549-
var collectiblesListItems: seq[TokenListItem]
548+
var tokenListItems: seq[token_list_item.TokenListItem]
549+
var collectiblesListItems: seq[token_list_item.TokenListItem]
550550

551551
let communityTokens = self.controller.getAllCommunityTokens()
552552
for community in communities:
@@ -571,34 +571,34 @@ proc buildTokensAndCollectiblesFromAllCommunities(self: Module) =
571571
self.buildTokensAndCollectiblesFromCommunities(communities)
572572

573573
proc buildTokensAndCollectiblesFromWallet(self: Module) =
574-
var tokenListItems: seq[TokenListItem]
575-
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)
574+
var tokenListItems: seq[token_list_item.TokenListItem]
575+
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

0 commit comments

Comments
 (0)