refactor(general): old `AppService` is renamed to `StatusFoundation`

`AppService` is renamed to `StatusFoundation` cause it doesn't contain
any more anything related to services. And it is moved to other location
`/src/app/core`. It contains a foundation for the app.

This part will rarely change
This commit is contained in:
Sale Djenic 2021-11-17 14:13:20 +01:00
parent e72b2d1007
commit 1ccc98af98
34 changed files with 306 additions and 239 deletions

View File

@ -67,7 +67,7 @@ proc changeLanguage(locale: string) =
type
AppController* = ref object of RootObj
appService: AppService
statusFoundation: StatusFoundation
# Global
localAppSettingsVariant: QVariant
localAccountSettingsVariant: QVariant
@ -126,14 +126,14 @@ proc mainDidLoad*(self: AppController)
# At the end of refactoring this will be moved to
# appropriate place or removed:
proc connect(self: AppController) =
self.appService.status.events.once("loginCompleted") do(a: Args):
self.statusFoundation.status.events.once("loginCompleted") do(a: Args):
var args = AccountArgs(a)
self.profile.init(args.account)
#################################################
proc newAppController*(appService: AppService): AppController =
proc newAppController*(statusFoundation: StatusFoundation): AppController =
result = AppController()
result.appService = appService
result.statusFoundation = statusFoundation
# Global
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
@ -142,21 +142,21 @@ proc newAppController*(appService: AppService): AppController =
result.userProfileVariant = newQVariant(singletonInstance.userProfile)
# Services
result.osNotificationService = os_notification_service.newService(appService.status.events)
result.keychainService = keychain_service.newService(appService.status.events)
result.osNotificationService = os_notification_service.newService(statusFoundation.status.events)
result.keychainService = keychain_service.newService(statusFoundation.status.events)
result.settingService = setting_service.newService()
result.settingsService = settings_service.newService()
result.accountsService = accounts_service.newService()
result.contactsService = contacts_service.newService(appService.status.events, appService.threadpool)
result.contactsService = contacts_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.chatService = chat_service.newService(result.contactsService)
result.communityService = community_service.newService(result.chatService)
result.messageService = message_service.newService(appService.status.events, appService.threadpool)
result.tokenService = token_service.newService(appService.status.events, appService.threadpool, result.settingService,
result.settingsService)
result.messageService = message_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.tokenService = token_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.settingService, result.settingsService)
result.collectibleService = collectible_service.newService(result.settingService)
result.walletAccountService = wallet_account_service.newService(appService.status.events, result.settingService,
result.walletAccountService = wallet_account_service.newService(statusFoundation.status.events, result.settingService,
result.tokenService)
result.transactionService = transaction_service.newService(appService.status.events, appService.threadpool,
result.transactionService = transaction_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.walletAccountService)
result.bookmarkService = bookmark_service.newService()
result.profileService = profile_service.newService()
@ -171,14 +171,14 @@ proc newAppController*(appService: AppService): AppController =
# Modules
result.startupModule = startup_module.newModule[AppController](
result,
appService.status.events,
appService.status.fleet,
statusFoundation.status.events,
statusFoundation.status.fleet,
result.keychainService,
result.accountsService
)
result.mainModule = main_module.newModule[AppController](
result,
appService.status.events,
statusFoundation.status.events,
result.keychainService,
result.accountsService,
result.chatService,
@ -204,18 +204,18 @@ proc newAppController*(appService: AppService): AppController =
#################################################
# At the end of refactoring this will be moved to
# appropriate place or removed:
result.profile = profile.newController(appService.status, appService, changeLanguage)
result.profile = profile.newController(statusFoundation.status, statusFoundation, changeLanguage)
result.connect()
#################################################
# Adding status and appService here now is just because of having a controll
# Adding status and statusFoundation here now is just because of having a controll
# over order of execution while we integrating this refactoring architecture
# into the current app state.
# Once we complete refactoring process we will get rid of "status" part/lib.
#
# This to will be adapted to appropriate modules later:
# result.login = login.newController(appService.status, appService)
# result.onboarding = onboarding.newController(appService.status)
# result.login = login.newController(statusFoundation.status, statusFoundation)
# result.onboarding = onboarding.newController(statusFoundation.status)
# singletonInstance.engine.setRootContextProperty("loginModel", result.login.variant)
# singletonInstance.engine.setRootContextProperty("onboardingModel", result.onboarding.variant)
#result.connect()
@ -269,7 +269,7 @@ proc startupDidLoad*(self: AppController) =
setLanguage(locale)
proc mainDidLoad*(self: AppController) =
self.appService.onLoggedIn()
self.statusFoundation.onLoggedIn()
self.startupModule.moveToAppState()
self.mainModule.checkForStoringPassword()
@ -279,8 +279,14 @@ proc start*(self: AppController) =
self.startupModule.load()
proc load(self: AppController) =
# init services which are available only if a user is logged in
proc load*(self: AppController) =
#################################################
# Once SettingService gets added, `pubKey` should be fetched from there, instead the following line:
let pubKey = self.statusFoundation.status.settings.getSetting[:string](Setting.PublicKey, "0x0")
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
#################################################
self.settingService.init()
self.contactsService.init()
self.chatService.init()
@ -300,14 +306,14 @@ proc load(self: AppController) =
self.buildAndRegisterUserProfile()
# load main module
self.mainModule.load(self.appService.status.events, self.chatService, self.communityService, self.messageService)
self.mainModule.load(self.statusFoundation.status.events, self.chatService, self.communityService, self.messageService)
proc userLoggedIn*(self: AppController) =
#################################################
# At the end of refactoring this will be removed:
let loggedInUser = self.accountsService.getLoggedInAccount()
let account = Account(name: loggedInUser.name, keyUid: loggedInUser.keyUid)
self.appService.status.events.emit("loginCompleted", AccountArgs(account: account))
self.statusFoundation.status.events.emit("loginCompleted", AccountArgs(account: account))
#################################################
self.load()

View File

@ -14,15 +14,15 @@ type ChatController* = ref object
view*: ChatsView
status*: Status
variant*: QVariant
appService: AppService
statusFoundation: StatusFoundation
uriToOpen: string
proc newController*(status: Status, appService: AppService, uriToOpen: string): ChatController =
proc newController*(status: Status, statusFoundation: StatusFoundation, uriToOpen: string): ChatController =
result = ChatController()
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.uriToOpen = uriToOpen
result.view = newChatsView(status, appService)
result.view = newChatsView(status, statusFoundation)
result.variant = newQVariant(result.view)
proc delete*(self: ChatController) =

View File

@ -184,7 +184,16 @@ proc handleChatEvents(self: ChatController) =
self.view.communities.markNotificationsAsRead(markAsReadProps)
proc handleMailserverEvents(self: ChatController) =
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
# TODO: test mailserver topics when joining chat
self.status.events.on("channelJoined") do(e:Args):
let task = IsActiveMailserverAvailableTaskArg(
`method`: "isActiveMailserverAvailable",
vptr: cast[ByteAddress](self.view.vptr),
slot: "isActiveMailserverResult"
)
mailserverWorker.start(task)
self.status.events.on("mailserverAvailable") do(e:Args):
self.view.messageView.setLoadingMessages(true)
let task = RequestMessagesTaskArg(

View File

@ -6,6 +6,27 @@ proc handleSignals(self: ChatController) =
var data = MessageSignal(e)
self.status.chat.update(data.chats, data.messages, data.emojiReactions, data.communities, data.membershipRequests, data.pinnedMessages, data.activityCenterNotification, data.statusUpdates, data.deletedMessages)
self.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
## Handle mailserver peers being added and removed
var data = DiscoverySummarySignal(e)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = PeerSummaryChangeTaskArg(
`method`: "peerSummaryChange",
peers: data.enodes
)
mailserverWorker.start(task)
self.status.events.on(SignalType.PeerStats.event) do(e:Args):
var data = PeerStatsSignal(e)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = PeerSummaryChangeTaskArg(
`method`: "peerSummaryChange",
peers: data.peers
)
mailserverWorker.start(task)
self.status.events.on(SignalType.EnvelopeSent.event) do(e:Args):
var data = EnvelopeSentSignal(e)
self.status.messages.updateStatus(data.messageIds)
@ -21,22 +42,12 @@ proc handleSignals(self: ChatController) =
var data = CommunitySignal(e)
self.view.communities.addCommunityToList(data.community)
self.status.events.on(SignalType.HistoryRequestStarted.event) do(e:Args):
self.view.messageView.setLoadingMessages(true)
self.status.events.on(SignalType.MailserverRequestCompleted.event) do(e:Args):
# TODO: if the signal contains a cursor, request additional messages
# else:
self.view.hideLoadingIndicator()
self.status.events.on(SignalType.HistoryRequestCompleted.event) do(e:Args):
self.view.messageView.setLoadingMessages(false)
self.status.events.on(SignalType.HistoryRequestFailed.event) do(e:Args):
self.view.messageView.setLoadingMessages(false)
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
self.status.events.on(SignalType.MailserverAvailable.event) do(e:Args):
var data = MailserverAvailableSignal(e)
info "active mailserver changed", node=data.address, topics="mailserver-interaction"
self.view.messageView.setLoadingMessages(true)
let task = RequestMessagesTaskArg(
`method`: "requestMessages",
vptr: cast[ByteAddress](self.view.vptr)
)
mailserverWorker.start(task)
self.status.events.on(SignalType.MailserverRequestExpired.event) do(e:Args):
# TODO: retry mailserver request up to N times or change mailserver
# If > N, then
self.view.hideLoadingIndicator()

View File

@ -3,6 +3,7 @@ import status/[status]
import status/utils as status_utils
import status/chat as status_chat
import status/messages as status_messages
import status/mailservers
import status/contacts as status_contacts
import status/ens as status_ens
import status/chat/[chat]
@ -43,7 +44,7 @@ proc getLinkPreviewData[T](self: T, slot: string, link: string, uuid: string) =
link: link,
uuid: uuid
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const asyncActivityNotificationLoadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[AsyncActivityNotificationLoadTaskArg](argEncoded)
@ -64,13 +65,13 @@ proc asyncActivityNotificationLoad[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type
ChatsView* = ref object of QAbstractListModel
status: Status
appService: AppService
statusFoundation: StatusFoundation
formatInputView: FormatInputView
ensView: EnsView
channelView*: ChannelView
@ -85,6 +86,7 @@ QtObject:
communities*: CommunitiesView
replyTo: string
connected: bool
timelineChat: Chat
pubKey*: string
proc setup(self: ChatsView) = self.QAbstractListModel.setup
@ -101,16 +103,16 @@ QtObject:
self.communities.delete
self.QAbstractListModel.delete
proc newChatsView*(status: Status, appService: AppService): ChatsView =
proc newChatsView*(status: Status, statusFoundation: StatusFoundation): ChatsView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.formatInputView = newFormatInputView()
result.ensView = newEnsView(status, appService)
result.ensView = newEnsView(status, statusFoundation)
result.communities = newCommunitiesView(status)
result.activityNotificationList = newActivityNotificationList(status)
result.channelView = newChannelView(status, appService, result.communities, result.activityNotificationList)
result.messageView = newMessageView(status, appService, result.channelView, result.communities)
result.channelView = newChannelView(status, statusFoundation, result.communities, result.activityNotificationList)
result.messageView = newMessageView(status, statusFoundation, result.channelView, result.communities)
result.connected = false
result.reactions = newReactionView(
status,
@ -118,7 +120,7 @@ QtObject:
result.messageView.pinnedMessagesList.addr,
result.channelView.activeChannel
)
result.stickers = newStickersView(status, appService, result.channelView.activeChannel)
result.stickers = newStickersView(status, statusFoundation, result.channelView.activeChannel)
result.gif = newGifView()
result.groups = newGroupsView(status,result.channelView.activeChannel)
result.transactions = newTransactionsView(status)
@ -207,18 +209,6 @@ QtObject:
return status_ens.userNameOrAlias(self.status.chat.getContacts()[pubKey])
generateAlias(pubKey)
proc getProfileThumbnail*(self: ChatsView, pubKey: string): string {.slot.} =
if self.status.chat.getContacts().hasKey(pubKey):
return self.status.chat.getContacts()[pubKey].identityImage.thumbnail
else:
return ""
proc getProfileImageLarge*(self: ChatsView, pubKey: string): string {.slot.} =
if self.status.chat.getContacts().hasKey(pubKey):
return self.status.chat.getContacts()[pubKey].identityImage.large
else:
return ""
proc activityNotificationsChanged*(self: ChatsView) {.signal.}
proc getActivityNotificationList(self: ChatsView): QVariant {.slot.} =
@ -242,6 +232,12 @@ QtObject:
self.activityNotificationList.addActivityNotificationItemToList(activityCenterNotification)
self.activityNotificationsChanged()
proc setActiveChannelToTimeline*(self: ChatsView) {.slot.} =
if not self.channelView.activeChannel.chatItem.isNil:
self.channelView.previousActiveChannelIndex = self.channelView.chats.chats.findIndexById(self.channelView.activeChannel.id)
self.channelView.activeChannel.setChatItem(self.timelineChat)
self.activeChannelChanged()
proc updateUsernames*(self:ChatsView, contacts: seq[Profile]) =
if contacts.len > 0:
# Updating usernames for all the messages list
@ -270,6 +266,9 @@ QtObject:
discard self.channelView.chats.addChatItemToList(chatItem)
self.messageView.messagePushed(self.messageView.messageList[chatItem.id].count - 1)
proc setTimelineChat*(self: ChatsView, chatItem: Chat) =
self.timelineChat = chatItem
proc copyToClipboard*(self: ChatsView, content: string) {.slot.} =
setClipBoardText(content)
@ -309,8 +308,16 @@ QtObject:
self.messageView.removeChat(chatId)
proc toggleReaction*(self: ChatsView, messageId: string, emojiId: int) {.slot.} =
if self.channelView.activeChannel.id == status_utils.getTimelineChatId():
let message = self.messageView.messageList[status_utils.getTimelineChatId()].getMessageById(messageId)
self.reactions.toggle(messageId, message.chatId, emojiId)
else:
self.reactions.toggle(messageId, self.channelView.activeChannel.id, emojiId)
proc removeMessagesFromTimeline*(self: ChatsView, chatId: string) =
self.messageView.messageList[status_utils.getTimelineChatId()].deleteMessagesByChatId(chatId)
self.channelView.activeChannelChanged()
proc updateChats*(self: ChatsView, chats: seq[Chat]) =
for chat in chats:
if (chat.communityId != ""):
@ -376,6 +383,17 @@ QtObject:
QtProperty[QVariant] transactions:
read = getTransactions
proc isActiveMailserverResult(self: ChatsView, resultEncoded: string) {.slot.} =
let isActiveMailserverAvailable = decode[bool](resultEncoded)
if isActiveMailserverAvailable:
self.messageView.setLoadingMessages(true)
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = RequestMessagesTaskArg(`method`: "requestMessages")
mailserverWorker.start(task)
proc requestAllHistoricMessagesResult(self: ChatsView, resultEncoded: string) {.slot.} =
self.messageView.setLoadingMessages(true)
proc createCommunityChannel*(self: ChatsView, communityId: string, name: string, description: string, categoryId: string): string {.slot.} =
try:
@ -420,7 +438,7 @@ QtObject:
proc requestMoreMessages*(self: ChatsView, fetchRange: int) {.slot.} =
self.messageView.loadingMessages = true
self.messageView.loadingMessagesChanged(true)
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
let task = RequestMessagesTaskArg( `method`: "requestMoreMessages", chatId: self.channelView.activeChannel.id)
mailserverWorker.start(task)
@ -436,6 +454,8 @@ QtObject:
proc pushPinnedMessages*(self: ChatsView, pinnedMessages: var seq[Message]) =
self.messageView.pushPinnedMessages(pinnedMessages)
proc hideLoadingIndicator*(self: ChatsView) {.slot.} =
self.messageView.hideLoadingIndicator()
proc deleteMessage*(self: ChatsView, channelId: string, messageId: string): bool =
result = self.messageView.deleteMessage(channelId, messageId)
@ -468,6 +488,15 @@ QtObject:
proc markMessageAsSent*(self: ChatsView, chat: string, messageId: string) =
self.messageView.markMessageAsSent(chat, messageId)
# TODO: this method was created just to test the store functionality.
# It should be removed, once peer management is added to status-go
proc requestAllHistoricMessages(self: ChatsView) {.slot.} =
debug "Requesting messages"
# TODO: the mailservers must change depending on whether we are using wakuV1 or wakuV2
# in the meantime I'm hardcoding a specific mailserver
echo self.status.mailservers.setMailserver("16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD")
echo self.status.mailservers.requestAllHistoricMessages()
proc switchTo*(self: ChatsView, communityId: string, channelId: string,
messageId: string) =
## This method displays community with communityId as an active one (if
@ -531,7 +560,7 @@ QtObject:
# Once this part gets refactored os notification service from the services will be used
# instead fetching that service from the "core/main"
#self.appService.osNotificationService.showNotification(title, message, details, useOSNotifications)
#self.statusFoundation.osNotificationService.showNotification(title, message, details, useOSNotifications)
##
##
#################################################

View File

@ -31,7 +31,7 @@ const asyncMarkAllReadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
QtObject:
type ChannelView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
communities*: CommunitiesView
chats*: ChannelsList
activeChannel*: ChatItemView
@ -46,10 +46,10 @@ QtObject:
self.contextChannel.delete
self.QObject.delete
proc newChannelView*(status: Status, appService: AppService, communities: CommunitiesView, activityNotificationList: ActivityNotificationList): ChannelView =
proc newChannelView*(status: Status, statusFoundation: StatusFoundation, communities: CommunitiesView, activityNotificationList: ActivityNotificationList): ChannelView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.chats = newChannelsList(status)
result.activeChannel = newChatItemView(status)
result.contextChannel = newChatItemView(status)
@ -117,7 +117,7 @@ QtObject:
slot: "onAsyncMarkMessagesRead",
chatId: chatId,
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
#################################################

View File

@ -30,20 +30,20 @@ proc resolveEns[T](self: T, slot: string, ens: string, uuid: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot, ens: ens, uuid: uuid
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type EnsView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
proc setup(self: EnsView) = self.QObject.setup
proc delete*(self: EnsView) = self.QObject.delete
proc newEnsView*(status: Status, appService: AppService): EnsView =
proc newEnsView*(status: Status, statusFoundation: StatusFoundation): EnsView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.setup
proc isEnsVerified*(self: EnsView, id: string): bool {.slot.} =

View File

@ -23,7 +23,7 @@ type
QtObject:
type MessageView* = ref object of QAbstractListModel
status: Status
appService: AppService
statusFoundation: StatusFoundation
messageList*: OrderedTable[string, ChatMessageList]
pinnedMessagesList*: OrderedTable[string, ChatMessageList]
channelView*: ChannelView
@ -46,10 +46,10 @@ QtObject:
self.channelOpenTime = initTable[string, int64]()
self.QAbstractListModel.delete
proc newMessageView*(status: Status, appService: AppService, channelView: ChannelView, communitiesView: CommunitiesView): MessageView =
proc newMessageView*(status: Status, statusFoundation: StatusFoundation, channelView: ChannelView, communitiesView: CommunitiesView): MessageView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.channelView = channelView
result.communities = communitiesView
result.messageList = initOrderedTable[string, ChatMessageList]()
@ -293,7 +293,7 @@ QtObject:
discard
# Not refactored yet, will be once we have corresponding qml part done.
# self.setLoadingHistoryMessages(channelId, true)
# self.appService.chatService.loadMoreMessagesForChannel(channelId)
# self.statusFoundation.chatService.loadMoreMessagesForChannel(channelId)
proc onMessagesLoaded*(self: MessageView, chatId: string, messages: var seq[Message]) =
self.pushMessages(messages)
@ -323,7 +323,7 @@ QtObject:
proc fillGaps*(self: MessageView, messageId: string) {.slot.} =
self.setLoadingMessages(true)
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
let mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
let task = FillGapsTaskArg( `method`: "fillGaps", chatId: self.channelView.activeChannel.id, messageIds: @[messageId])
mailserverWorker.start(task)

View File

@ -52,7 +52,7 @@ proc estimate[T](self: T, slot: string, packId: int, address: string, price: str
price: price,
uuid: uuid
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const obtainAvailableStickerPacksTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[ObtainAvailableStickerPacksTaskArg](argEncoded)
@ -68,14 +68,14 @@ proc obtainAvailableStickerPacks[T](self: T, slot: string) =
tptr: cast[ByteAddress](obtainAvailableStickerPacksTask),
vptr: cast[ByteAddress](self.vptr),
slot: slot,
running: cast[ByteAddress](addr self.appService.threadpool.running)
running: cast[ByteAddress](addr self.statusFoundation.threadpool.running)
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type StickersView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
activeChannel: ChatItemView
stickerPacks*: StickerPackList
recentStickers*: StickerList
@ -86,11 +86,11 @@ QtObject:
proc delete*(self: StickersView) =
self.QObject.delete
proc newStickersView*(status: Status, appService: AppService, activeChannel: ChatItemView): StickersView =
proc newStickersView*(status: Status, statusFoundation: StatusFoundation, activeChannel: ChatItemView): StickersView =
new(result, delete)
result = StickersView()
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.stickerPacks = newStickerPackList()
result.recentStickers = newStickerList()
result.activeChannel = activeChannel

View File

@ -10,17 +10,16 @@ import
export status_lib_status
export marathon, task_runner, signals_manager
type AppService* = ref object # AppService should be renamed to "Foundation"
type StatusFoundation* = ref object
status*: Status # in one point of time this should be completely removed
# foundation
threadpool*: ThreadPool
marathon*: Marathon
signalsManager*: SignalsManager
mailserverController*: MailserverController
mailserverWorker*: MailserverWorker
proc newAppService*(status: Status): AppService =
result = AppService()
proc newStatusFoundation*(status: Status): StatusFoundation =
result = StatusFoundation()
result.status = status
result.mailserverController = newMailserverController(status)
result.mailserverWorker = newMailserverWorker(cast[ByteAddress](result.mailserverController.vptr))
@ -28,11 +27,11 @@ proc newAppService*(status: Status): AppService =
result.marathon = newMarathon(result.mailserverWorker)
result.signalsManager = newSignalsManager(status.events)
proc delete*(self: AppService) =
proc delete*(self: StatusFoundation) =
self.threadpool.teardown()
self.marathon.teardown()
self.signalsManager.delete()
proc onLoggedIn*(self: AppService) =
proc onLoggedIn*(self: StatusFoundation) =
self.marathon.onLoggedIn()
self.osNotificationService.onLoggedIn()

View File

@ -8,16 +8,16 @@ logScope:
topics = "node"
type NodeController* = ref object
appService: AppService
statusFoundation: StatusFoundation
view*: NodeView
variant*: QVariant
networkAccessMananger*: QNetworkAccessManager
isWakuV2: bool
proc newController*(appService: AppService, nam: QNetworkAccessManager): NodeController =
proc newController*(statusFoundation: StatusFoundation, nam: QNetworkAccessManager): NodeController =
result = NodeController()
result.appService = appService
result.view = newNodeView(appService)
result.statusFoundation = statusFoundation
result.view = newNodeView(statusFoundation)
result.variant = newQVariant(result.view)
result.networkAccessMananger = nam
@ -26,30 +26,30 @@ proc delete*(self: NodeController) =
delete self.view
proc setPeers(self: NodeController, peers: seq[string]) =
self.appService.status.network.peerSummaryChange(peers)
self.statusFoundation.status.network.peerSummaryChange(peers)
self.view.setPeerSize(peers.len)
proc init*(self: NodeController) =
self.isWakuV2 = self.appService.status.settings.getWakuVersion() == 2
self.isWakuV2 = self.statusFoundation.status.settings.getWakuVersion() == 2
self.appService.status.events.on(SignalType.Wallet.event) do(e:Args):
self.statusFoundation.status.events.on(SignalType.Wallet.event) do(e:Args):
self.view.setLastMessage($WalletSignal(e).blockNumber)
self.appService.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
self.statusFoundation.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
var data = DiscoverySummarySignal(e)
self.setPeers(data.enodes)
self.appService.status.events.on(SignalType.PeerStats.event) do(e:Args):
self.statusFoundation.status.events.on(SignalType.PeerStats.event) do(e:Args):
var data = PeerStatsSignal(e)
self.setPeers(data.peers)
self.appService.status.events.on(SignalType.Stats.event) do (e:Args):
self.statusFoundation.status.events.on(SignalType.Stats.event) do (e:Args):
self.view.setStats(StatsSignal(e).stats)
if not self.isWakuV2: self.view.fetchBitsSet()
self.appService.status.events.on(SignalType.ChroniclesLogs.event) do(e:Args):
self.statusFoundation.status.events.on(SignalType.ChroniclesLogs.event) do(e:Args):
self.view.log(ChroniclesLogsSignal(e).content)
self.view.init()
self.setPeers(self.appService.status.network.fetchPeers())
self.setPeers(self.statusFoundation.status.network.fetchPeers())

View File

@ -23,12 +23,12 @@ proc bloomFiltersBitsSet[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type NodeView* = ref object of QObject
appService: AppService
statusFoundation: StatusFoundation
callResult: string
lastMessage*: string
wakuBloomFilterMode*: bool
@ -41,9 +41,9 @@ QtObject:
proc setup(self: NodeView) =
self.QObject.setup
proc newNodeView*(appService: AppService): NodeView =
proc newNodeView*(statusFoundation: StatusFoundation): NodeView =
new(result)
result.appService = appService
result.statusFoundation = statusFoundation
result.callResult = "Use this tool to call JSONRPC methods"
result.lastMessage = ""
result.wakuBloomFilterMode = false
@ -72,7 +72,7 @@ QtObject:
notify = callResultChanged
proc onSend*(self: NodeView, inputJSON: string) {.slot.} =
self.setCallResult(self.appService.status.node.sendRPCMessageRaw(inputJSON))
self.setCallResult(self.statusFoundation.status.node.sendRPCMessageRaw(inputJSON))
echo "Done!: ", self.callResult
proc onMessage*(self: NodeView, message: string) {.slot.} =
@ -114,20 +114,20 @@ QtObject:
notify = initialized
proc setWakuBloomFilterMode*(self: NodeView, bloomFilterMode: bool) {.slot.} =
let statusGoResult = self.appService.status.settings.setBloomFilterMode(bloomFilterMode)
let statusGoResult = self.statusFoundation.status.settings.setBloomFilterMode(bloomFilterMode)
if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
proc init*(self: NodeView) {.slot.} =
let nodeConfig = self.appService.status.settings.getNodeConfig()
self.wakuBloomFilterMode = self.appService.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode)
let nodeConfig = self.statusFoundation.status.settings.getNodeConfig()
self.wakuBloomFilterMode = self.statusFoundation.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode)
self.fullNode = nodeConfig["WakuConfig"]["FullNode"].getBool()
self.wakuV2LightClient = nodeConfig["WakuV2Config"]{"LightClient"}.getBool()
self.initialized()
proc wakuVersion*(self: NodeView): int {.slot.} =
var fleetStr = self.appService.status.settings.getSetting[:string](Setting.Fleet)
var fleetStr = self.statusFoundation.status.settings.getSetting[:string](Setting.Fleet)
let fleet = parseEnum[Fleet](fleetStr)
let isWakuV2 = if fleet == WakuV2Prod or fleet == WakuV2Test: true else: false
if isWakuV2: return 2
@ -147,7 +147,7 @@ QtObject:
BloomFilterMode = true
FullNode = false
let statusGoResult = self.appService.status.settings.setBloomLevel(BloomFilterMode, FullNode)
let statusGoResult = self.statusFoundation.status.settings.setBloomLevel(BloomFilterMode, FullNode)
if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
@ -210,7 +210,7 @@ QtObject:
notify = initialized
proc setWakuV2LightClient*(self: NodeView, enabled: bool) {.slot.} =
let statusGoResult = self.appService.status.settings.setV2LightMode(enabled)
let statusGoResult = self.statusFoundation.status.settings.setV2LightMode(enabled)
if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error
else:

View File

@ -21,14 +21,14 @@ type ProfileController* = ref object
view*: ProfileView
variant*: QVariant
status: Status
appService: AppService
statusFoundation: StatusFoundation
proc newController*(status: Status, appService: AppService,
proc newController*(status: Status, statusFoundation: StatusFoundation,
changeLanguage: proc(locale: string)): ProfileController =
result = ProfileController()
result.status = status
result.appService = appService
result.view = newProfileView(status, appService, changeLanguage)
result.statusFoundation = statusFoundation
result.view = newProfileView(status, statusFoundation, changeLanguage)
result.variant = newQVariant(result.view)
proc delete*(self: ProfileController) =

View File

@ -32,7 +32,7 @@ QtObject:
fleets*: Fleets
network*: NetworkView
status*: Status
appService: AppService
statusFoundation: StatusFoundation
changeLanguage*: proc(locale: string)
ens*: EnsManager
@ -51,7 +51,7 @@ QtObject:
if not self.mailservers.isNil: self.mailservers.delete
self.QObject.delete
proc newProfileView*(status: Status, appService: AppService,
proc newProfileView*(status: Status, statusFoundation: StatusFoundation,
changeLanguage: proc(locale: string)): ProfileView =
new(result, delete)
result = ProfileView()
@ -61,12 +61,12 @@ QtObject:
result.devices = newDevicesView(status)
result.network = newNetworkView(status)
result.mnemonic = newMnemonicView(status)
result.mailservers = newMailserversView(status, appService)
result.ens = newEnsManager(status, appService)
result.mailservers = newMailserversView(status, statusFoundation)
result.ens = newEnsManager(status, statusFoundation)
result.fleets = newFleets(status)
result.changeLanguage = changeLanguage
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.setup
proc initialized*(self: ProfileView) {.signal.}
@ -188,7 +188,7 @@ QtObject:
# Once this part gets refactored os notification service from the services will be used
# instead fetching that service from the "core/main"
#self.appService.osNotificationService.showNotification(title, message, details, useOSNotifications)
#self.statusFoundation.osNotificationService.showNotification(title, message, details, useOSNotifications)
proc logDir*(self: ProfileView): string {.slot.} =
url_fromLocalFile(constants.LOGDIR)

View File

@ -32,12 +32,12 @@ proc lookupContact[T](self: T, slot: string, value: string) =
slot: slot,
value: value
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type ContactsView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
contactList*: ContactList
contactRequests*: ContactList
addedContacts*: ContactList
@ -55,10 +55,10 @@ QtObject:
self.blockedContacts.delete
self.QObject.delete
proc newContactsView*(status: Status, appService: AppService): ContactsView =
proc newContactsView*(status: Status, statusFoundation: StatusFoundation): ContactsView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.contactList = newContactList()
result.contactRequests = newContactList()
result.addedContacts = newContactList()

View File

@ -39,7 +39,7 @@ proc validate[T](self: T, slot: string, ens: string, isStatus: bool, usernames:
isStatus: isStatus,
usernames: usernames
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const detailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
@ -70,14 +70,14 @@ proc details[T](self: T, slot: string, username: string) =
slot: slot,
username: username
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type EnsManager* = ref object of QAbstractListModel
usernames*: seq[string]
pendingUsernames*: HashSet[string]
status: Status
appService: AppService
statusFoundation: StatusFoundation
proc setup(self: EnsManager) = self.QAbstractListModel.setup
@ -85,11 +85,11 @@ QtObject:
self.usernames = @[]
self.QAbstractListModel.delete
proc newEnsManager*(status: Status, appService: AppService): EnsManager =
proc newEnsManager*(status: Status, statusFoundation: StatusFoundation): EnsManager =
new(result, delete)
result.usernames = @[]
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.pendingUsernames = initHashSet[string]()
result.setup

View File

@ -13,9 +13,8 @@ logScope:
QtObject:
type MailserversView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
mailserversList*: MailServersList
activeMailserver: string
proc setup(self: MailserversView) =
self.QObject.setup
@ -24,10 +23,10 @@ QtObject:
self.mailserversList.delete
self.QObject.delete
proc newMailserversView*(status: Status, appService: AppService): MailserversView =
proc newMailserversView*(status: Status, statusFoundation: StatusFoundation): MailserversView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.mailserversList = newMailServersList()
result.setup
@ -40,16 +39,21 @@ QtObject:
QtProperty[QVariant] list:
read = getMailserversList
proc activeMailserverChanged*(self: MailserversView, activeMailserver: string) {.signal.}
proc activeMailserverChanged*(self: MailserversView, activeMailserverName: string) {.signal.}
proc setActiveMailserver*(self: MailserversView, activeMailserver: string) =
self.activeMailserver = activeMailserver
proc getActiveMailserver(self: MailserversView): string {.slot.} =
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = GetActiveMailserverTaskArg(
`method`: "getActiveMailserver",
vptr: cast[ByteAddress](self.vptr),
slot: "getActiveMailserverResult"
)
mailserverWorker.start(task)
proc getActiveMailserverResult*(self: MailserversView, activeMailserver: string) {.slot.} =
self.activeMailserverChanged(activeMailserver)
QtProperty[string] activeMailserver:
read = activeMailserver
notify = activeMailserverChanged
proc getAutomaticSelection(self: MailserversView): bool {.slot.} =
self.status.settings.getPinnedMailserver() == ""
@ -62,10 +66,19 @@ QtObject:
proc enableAutomaticSelection(self: MailserversView, value: bool) {.slot.} =
if value:
self.activeMailserverChanged(self.activeMailserver)
self.status.settings.pinMailserver()
else:
self.activeMailserverChanged("")
let
mailserverWorker = self.statusFoundation.marathon[MailserverWorker().name]
task = GetActiveMailserverTaskArg(
`method`: "getActiveMailserver",
vptr: cast[ByteAddress](self.vptr),
slot: "getActiveMailserverResult2"
)
mailserverWorker.start(task)
proc getActiveMailserverResult2(self: MailserversView, activeMailserver: string) {.slot.} =
self.status.settings.pinMailserver(activeMailserver)
proc save(self: MailserversView, name: string, address: string) {.slot.} =
self.status.settings.saveMailserver(name, address)

View File

@ -9,15 +9,15 @@ logScope:
type UtilsController* = ref object
status*: Status
appService: AppService
statusFoundation: StatusFoundation
view*: UtilsView
variant*: QVariant
proc newController*(status: Status, appService: AppService): UtilsController =
proc newController*(status: Status, statusFoundation: StatusFoundation): UtilsController =
result = UtilsController()
result.status = status
result.appService = appService
result.view = newUtilsView(status, appService)
result.statusFoundation = statusFoundation
result.view = newUtilsView(status, statusFoundation)
result.variant = newQVariant(result.view)
proc delete*(self: UtilsController) =

View File

@ -21,7 +21,7 @@ type CheckForNewVersionTaskArg = ref object of QObjectTaskArg
QtObject:
type UtilsView* = ref object of QObject
status*: Status
appService: AppService
statusFoundation: StatusFoundation
newVersion*: string
proc setup(self: UtilsView) =
@ -35,11 +35,11 @@ QtObject:
proc delete*(self: UtilsView) =
self.QObject.delete
proc newUtilsView*(status: Status, appService: AppService): UtilsView =
proc newUtilsView*(status: Status, statusFoundation: StatusFoundation): UtilsView =
new(result, delete)
result = UtilsView()
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.setup
proc getOs*(self: UtilsView): string {.slot.} =
@ -168,7 +168,7 @@ QtObject:
vptr: cast[ByteAddress](self.vptr),
slot: slot
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
proc latestVersionSuccess*(self: UtilsView, latestVersionJSON: string) {.slot.} =
let latestVersionObj = parseJSON(latestVersionJSON)

View File

@ -14,15 +14,15 @@ logScope:
type WalletController* = ref object
status: Status
appService: AppService
statusFoundation: StatusFoundation
view*: WalletView
variant*: QVariant
proc newController*(status: Status, appService: AppService): WalletController =
proc newController*(status: Status, statusFoundation: StatusFoundation): WalletController =
result = WalletController()
result.status = status
result.appService = appService
result.view = newWalletView(status, appService)
result.statusFoundation = statusFoundation
result.view = newWalletView(status, statusFoundation)
result.variant = newQVariant(result.view)
proc delete*(self: WalletController) =

View File

@ -10,7 +10,7 @@ QtObject:
type
WalletView* = ref object of QAbstractListModel
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView: AccountsView
collectiblesView: CollectiblesView
transactionsView*: TransactionsView
@ -37,19 +37,19 @@ QtObject:
proc setup(self: WalletView) =
self.QAbstractListModel.setup
proc newWalletView*(status: Status, appService: AppService): WalletView =
proc newWalletView*(status: Status, statusFoundation: StatusFoundation): WalletView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.accountsView = newAccountsView(status)
result.collectiblesView = newCollectiblesView(status, appService, result.accountsView)
result.transactionsView = newTransactionsView(status, appService, result.accountsView)
result.tokensView = newTokensView(status, appService, result.accountsView)
result.gasView = newGasView(status, appService)
result.collectiblesView = newCollectiblesView(status, statusFoundation, result.accountsView)
result.transactionsView = newTransactionsView(status, statusFoundation, result.accountsView)
result.tokensView = newTokensView(status, statusFoundation, result.accountsView)
result.gasView = newGasView(status, statusFoundation)
result.dappBrowserView = newDappBrowserView(status, result.accountsView)
result.historyView = newHistoryView(status, appService, result.accountsView, result.transactionsView)
result.balanceView = newBalanceView(status, appService, result.accountsView, result.transactionsView, result.historyView)
result.historyView = newHistoryView(status, statusFoundation, result.accountsView, result.transactionsView)
result.balanceView = newBalanceView(status, statusFoundation, result.accountsView, result.transactionsView, result.historyView)
result.utilsView = newUtilsView()
result.isNonArchivalNode = false

View File

@ -35,12 +35,12 @@ proc initBalances[T](self: T, slot: string, address: string, tokenList: seq[stri
vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, tokenList: tokenList
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type BalanceView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
totalFiatBalance: string
accountsView: AccountsView
transactionsView*: TransactionsView
@ -49,10 +49,10 @@ QtObject:
proc setup(self: BalanceView) = self.QObject.setup
proc delete(self: BalanceView) = self.QObject.delete
proc newBalanceView*(status: Status, appService: AppService, accountsView: AccountsView, transactionsView: TransactionsView, historyView: HistoryView): BalanceView =
proc newBalanceView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView, transactionsView: TransactionsView, historyView: HistoryView): BalanceView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.totalFiatBalance = ""
result.accountsView = accountsView
result.transactionsView = transactionsView

View File

@ -44,14 +44,14 @@ proc loadCollectibles[T](self: T, slot: string, address: string, collectiblesTyp
tptr: cast[ByteAddress](loadCollectiblesTask),
vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, collectiblesType: collectiblesType,
running: cast[ByteAddress](addr self.appService.threadpool.running)
running: cast[ByteAddress](addr self.statusFoundation.threadpool.running)
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type CollectiblesView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView*: AccountsView
currentCollectiblesLists*: CollectiblesList
@ -60,10 +60,10 @@ QtObject:
self.currentCollectiblesLists.delete
self.QObject.delete
proc newCollectiblesView*(status: Status, appService: AppService, accountsView: AccountsView): CollectiblesView =
proc newCollectiblesView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): CollectiblesView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.currentCollectiblesLists = newCollectiblesList()
result.accountsView = accountsView # TODO: not ideal but a solution for now
result.setup

View File

@ -31,7 +31,7 @@ proc getGasPredictions[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
logScope:
topics = "gas-view"
@ -39,17 +39,17 @@ logScope:
QtObject:
type GasView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
gasPrice: string
defaultGasLimit: string
proc setup(self: GasView) = self.QObject.setup
proc delete(self: GasView) = self.QObject.delete
proc newGasView*(status: Status, appService: AppService): GasView =
proc newGasView*(status: Status, statusFoundation: StatusFoundation): GasView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.gasPrice = "0"
result.defaultGasLimit = "21000"
result.setup

View File

@ -40,12 +40,12 @@ proc loadTransactions*[T](self: T, slot: string, address: string, toBlock: Uint2
limit: limit,
loadMore: loadMore
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type HistoryView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView: AccountsView
transactionsView*: TransactionsView
fetchingHistoryState: Table[string, bool]
@ -53,11 +53,11 @@ QtObject:
proc setup(self: HistoryView) = self.QObject.setup
proc delete(self: HistoryView) = self.QObject.delete
proc newHistoryView*(status: Status, appService: AppService,
proc newHistoryView*(status: Status, statusFoundation: StatusFoundation,
accountsView: AccountsView, transactionsView: TransactionsView): HistoryView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.fetchingHistoryState = initTable[string, bool]()
result.accountsView = accountsView
result.transactionsView = transactionsView

View File

@ -53,12 +53,12 @@ proc getTokenDetails[T](self: T, slot: string, chainId: int, address: string) =
slot: slot,
chainId: chainId,
address: address)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type TokenList* = ref object of QAbstractListModel
status: Status
appService: AppService
statusFoundation: StatusFoundation
tokens*: seq[Erc20Contract]
isCustom*: bool
@ -85,11 +85,11 @@ QtObject:
self.isCustom = true
self.endResetModel()
proc newTokenList*(status: Status, appService: AppService): TokenList =
proc newTokenList*(status: Status, statusFoundation: StatusFoundation): TokenList =
new(result, delete)
result.tokens = @[]
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.setup
proc rowData(self: TokenList, index: int, column: string): string {.slot.} =

View File

@ -11,7 +11,7 @@ logScope:
QtObject:
type TokensView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView: AccountsView
currentAssetList*: AssetList
defaultTokenList: TokenList
@ -24,14 +24,14 @@ QtObject:
self.customTokenList.delete
self.QObject.delete
proc newTokensView*(status: Status, appService: AppService, accountsView: AccountsView): TokensView =
proc newTokensView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): TokensView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.accountsView = accountsView
result.currentAssetList = newAssetList()
result.defaultTokenList = newTokenList(status, appService)
result.customTokenList = newTokenList(status, appService)
result.defaultTokenList = newTokenList(status, statusFoundation)
result.customTokenList = newTokenList(status, statusFoundation)
result.setup
proc hasAsset*(self: TokensView, symbol: string): bool {.slot.} =

View File

@ -53,7 +53,7 @@ proc sendTransaction[T](self: T, slot: string, from_addr: string, to: string, as
gasPrice: gasPrice, password: password, uuid: uuid,
isEIP1559Enabled: isEIP1559Enabled, maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const watchTransactionTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
@ -68,12 +68,12 @@ proc watchTransaction[T](self: T, slot: string, transactionHash: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot, transactionHash: transactionHash
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type TransactionsView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView*: AccountsView
currentTransactions*: TransactionList
@ -82,10 +82,10 @@ QtObject:
self.currentTransactions.delete
self.QObject.delete
proc newTransactionsView*(status: Status, appService: AppService, accountsView: AccountsView): TransactionsView =
proc newTransactionsView*(status: Status, statusFoundation: StatusFoundation, accountsView: AccountsView): TransactionsView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.accountsView = accountsView # TODO: not ideal but a solution for now
result.currentTransactions = newTransactionList()
result.setup

View File

@ -14,15 +14,15 @@ logScope:
type WalletController* = ref object
status: Status
appService: AppService
statusFoundation: StatusFoundation
view*: WalletView
variant*: QVariant
proc newController*(status: Status, appService: AppService): WalletController =
proc newController*(status: Status, statusFoundation: StatusFoundation): WalletController =
result = WalletController()
result.status = status
result.appService = appService
result.view = newWalletView(status, appService)
result.statusFoundation = statusFoundation
result.view = newWalletView(status, statusFoundation)
result.variant = newQVariant(result.view)
proc delete*(self: WalletController) =

View File

@ -13,7 +13,7 @@ QtObject:
type
WalletView* = ref object of QAbstractListModel
status: Status
appService: AppService
statusFoundation: StatusFoundation
accountsView: AccountsView
collectiblesView: CollectiblesView
settingsView*: SettingsView
@ -33,16 +33,16 @@ QtObject:
proc setup(self: WalletView) =
self.QAbstractListModel.setup
proc newWalletView*(status: Status, appService: AppService): WalletView =
proc newWalletView*(status: Status, statusFoundation: StatusFoundation): WalletView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.accountsView = newAccountsView(status)
result.collectiblesView = newCollectiblesView(status, appService)
result.collectiblesView = newCollectiblesView(status, statusFoundation)
result.settingsView = newSettingsView()
result.networksView = newNetworksView(status)
result.cryptoServiceController = newCryptoServiceController(status, appService)
result.savedAddressesView = newSavedAddressesView(status, appService)
result.cryptoServiceController = newCryptoServiceController(status, statusFoundation)
result.savedAddressesView = newSavedAddressesView(status, statusFoundation)
result.setup
proc getAccounts(self: WalletView): QVariant {.slot.} =

View File

@ -28,7 +28,7 @@ const asyncGetCryptoServicesTask: Task = proc(argEncoded: string) {.gcsafe, nimc
QtObject:
type CryptoServiceController* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
cryptoServiceModel: CryptoServiceModel
servicesFetched: bool
@ -39,11 +39,11 @@ QtObject:
self.cryptoServiceModel.delete
self.QObject.delete
proc newCryptoServiceController*(status: Status, appService: AppService):
proc newCryptoServiceController*(status: Status, statusFoundation: StatusFoundation):
CryptoServiceController =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.cryptoServiceModel = newCryptoServiceModel()
result.servicesFetched = false
result.setup
@ -68,7 +68,7 @@ QtObject:
vptr: cast[ByteAddress](self.vptr),
slot: "onAsyncFetchCryptoServices"
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
#################################################
proc fetchCryptoServicesFetched*(self:CryptoServiceController) {.signal.}

View File

@ -24,7 +24,7 @@ proc loadCollections[T](self: T, slot: string, address: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address,
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
type
LoadAssetsTaskArg = ref object of QObjectTaskArg
@ -46,12 +46,12 @@ proc loadAssets[T](self: T, slot: string, address: string, collectionSlug: strin
vptr: cast[ByteAddress](self.vptr),
slot: slot, address: address, collectionSlug: collectionSlug, limit: 200
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type CollectiblesView* = ref object of QObject
status: Status
appService: AppService
statusFoundation: StatusFoundation
collections: CollectionList
isLoading: bool
assets: Table[string, AssetList]
@ -64,10 +64,10 @@ QtObject:
list.delete
self.QObject.delete
proc newCollectiblesView*(status: Status, appService: AppService): CollectiblesView =
proc newCollectiblesView*(status: Status, statusFoundation: StatusFoundation): CollectiblesView =
new(result, delete)
result.status = status
result.appService = appService
result.statusFoundation = statusFoundation
result.collections = newCollectionList()
result.assets = initTable[string, AssetList]()
result.isLoading = false

View File

@ -37,7 +37,7 @@ proc loadSavedAddresses[T](self: T, slot: string) =
vptr: cast[ByteAddress](self.vptr),
slot: slot
)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const addSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
@ -57,7 +57,7 @@ proc addSavedAddress[T](self: T, slot, name, address: string) =
except:
raise newException(ValueError, "Error parsing address")
arg.savedAddress = SavedAddress(name: name, address: addressParsed)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const deleteSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
@ -77,7 +77,7 @@ proc deleteSavedAddress[T](self: T, slot, address: string) =
except:
raise newException(ValueError, "Error parsing address")
arg.address = addressParsed
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
const editSavedAddressTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
@ -97,14 +97,14 @@ proc editSavedAddress[T](self: T, slot, name, address: string) =
except:
raise newException(ValueError, "Error parsing address")
arg.savedAddress = SavedAddress(name: name, address: addressParsed)
self.appService.threadpool.start(arg)
self.statusFoundation.threadpool.start(arg)
QtObject:
type
SavedAddressesView* = ref object of QObject
# no need to store the seq[SavedAddress] value in `loadResult`, as it is
# set in self.savedAddresses
appService: AppService
statusFoundation: StatusFoundation
addEditResult: SavedAddressResult[void]
deleteResult: SavedAddressResult[void]
loadResult: SavedAddressResult[void]
@ -117,10 +117,10 @@ QtObject:
self.savedAddresses.delete
self.QObject.delete
proc newSavedAddressesView*(status: Status, appService: AppService): SavedAddressesView =
proc newSavedAddressesView*(status: Status, statusFoundation: StatusFoundation): SavedAddressesView =
new(result, delete)
result.addEditResult = SavedAddressResult[void].ok()
result.appService = appService
result.statusFoundation = statusFoundation
result.deleteResult = SavedAddressResult[void].ok()
result.savedAddresses = newSavedAddressesList()
result.setup

View File

@ -38,8 +38,8 @@ proc mainProc() =
fleetConfig = readFile(joinPath(getAppDir(), fleets))
status = statuslib.newStatusInstance(fleetConfig)
let appService = newAppService(status)
defer: appService.delete()
let statusFoundation = newStatusFoundation(status)
defer: statusFoundation.delete()
status.initNode(STATUSGODIR, KEYSTOREDIR)
@ -50,7 +50,7 @@ proc mainProc() =
let app = newQGuiApplication()
defer: app.delete()
let appController = newAppController(appService)
let appController = newAppController(statusFoundation)
defer: appController.delete()
let resources =
@ -117,7 +117,7 @@ proc mainProc() =
# We need this global variable in order to be able to access the application
# from the non-closure callback passed to `statusgo_backend.setSignalEventCallback`
signalsManagerQObjPointer = cast[pointer](appService.signalsManager.vptr)
signalsManagerQObjPointer = cast[pointer](statusFoundation.signalsManager.vptr)
defer:
signalsManagerQObjPointer = nil
@ -133,23 +133,23 @@ proc mainProc() =
let logFile = fmt"app_{getTime().toUnix}.log"
discard defaultChroniclesStream.outputs[1].open(LOGDIR & logFile, fmAppend)
var wallet = wallet.newController(status, appService)
var wallet = wallet.newController(status, statusFoundation)
defer: wallet.delete()
singletonInstance.engine.setRootContextProperty("walletModel", wallet.variant)
var wallet2 = walletV2.newController(status, appService)
var wallet2 = walletV2.newController(status, statusFoundation)
defer: wallet2.delete()
singletonInstance.engine.setRootContextProperty("walletV2Model", wallet2.variant)
var chat = chat.newController(status, appService, OPENURI)
var chat = chat.newController(status, statusFoundation, OPENURI)
defer: chat.delete()
singletonInstance.engine.setRootContextProperty("chatsModel", chat.variant)
var node = node.newController(appService, netAccMgr)
var node = node.newController(statusFoundation, netAccMgr)
defer: node.delete()
singletonInstance.engine.setRootContextProperty("nodeModel", node.variant)
var utilsController = utilsView.newController(status, appService)
var utilsController = utilsView.newController(status, statusFoundation)
defer: utilsController.delete()
singletonInstance.engine.setRootContextProperty("utilsModel", utilsController.variant)
@ -204,9 +204,9 @@ proc mainProc() =
# 2. Re-init controllers that don't require a running node
initControllers()
var signalsManagerQVariant = newQVariant(appService.signalsManager)
var signalsManagerQVariant = newQVariant(statusFoundation.signalsManager)
defer: signalsManagerQVariant.delete()
var mailserverControllerQVariant = newQVariant(appService.mailserverController)
var mailserverControllerQVariant = newQVariant(statusFoundation.mailserverController)
defer: mailserverControllerQVariant.delete()
singletonInstance.engine.setRootContextProperty("signals", signalsManagerQVariant)