Revert "refactor(general): modules' structure aligned"

This reverts commit 6154a89cf6.
This commit is contained in:
Jonathan Rainville 2021-11-25 12:44:10 -05:00 committed by Sale Djenic
parent 10268ec3c4
commit 15378c4e4e
76 changed files with 484 additions and 794 deletions

View File

@ -60,8 +60,7 @@ method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.appSearchDidLoad()
self.delegate.chatSectionDidLoad()
method getModuleAsVariant*(self: Module): QVariant =
return self.viewVariant

View File

@ -33,18 +33,23 @@ method delete*(self: Module) =
method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("bookmarkModule", self.viewVariant)
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
let bookmarks = self.controller.getBookmarks()
for b in bookmarks:
self.view.addItem(initItem(b.name, b.url, b.imageUrl))
method isLoaded*(self: Module): bool =
return self.moduleLoaded
proc checkIfModuleDidLoad(self: Module) =
self.moduleLoaded = true
self.delegate.bookmarkDidLoad()
method providerDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method viewDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method storeBookmark*(self: Module, url: string, name: string) =
if url == "":
self.view.addItem(initItem(name, url, "")) # These URLs are not stored but added direclty to the UI

View File

@ -46,15 +46,21 @@ method fetchPermissions(self: Module, dapp: string) =
method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("dappPermissionsModule", self.viewVariant)
self.view.load()
self.fetchDapps()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.fetchDapps()
proc checkIfModuleDidLoad(self: Module) =
self.moduleLoaded = true
self.delegate.dappsDidLoad()
method dappsDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method viewDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method hasPermission*(self: Module, hostname: string, permission: string): bool =
self.controller.hasPermission(hostname, permission.toPermission())

View File

@ -48,10 +48,13 @@ method setDappsAddress*(self: Module, value: string) =
method onDappAddressChanged*(self: Module, value: string) =
self.view.dappsAddress = value
method viewDidLoad*(self: Module) =
proc checkIfModuleDidLoad(self: Module) =
self.moduleLoaded = true
self.delegate.providerDidLoad()
method viewDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method disconnect*(self: Module) =
self.controller.disconnect()

View File

@ -10,7 +10,7 @@ include ./private_interfaces/module_controller_delegate_interface
# Defines how submodules of this module communicate with this module
include ./private_interfaces/module_chat_section_delegate_interface
include ./private_interfaces/module_app_search_delegate_interface
include ./private_interfaces/module_community_section_delegate_interface
include ./private_interfaces/module_browser_section_delegate_interface
# This way (using concepts) is used only for the modules managed by AppController

View File

@ -247,9 +247,6 @@ proc checkIfModuleDidLoad [T](self: Module[T]) =
if(not self.stickersModule.isLoaded()):
return
if(not self.appSearchModule.isLoaded()):
return
self.moduleLoaded = true
self.delegate.mainDidLoad()
@ -259,12 +256,6 @@ method chatSectionDidLoad*[T](self: Module[T]) =
method communitySectionDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method appSearchDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
proc stickersDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
proc walletSectionDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()

View File

@ -1,2 +0,0 @@
method appSearchDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -1,8 +1,5 @@
method chatSectionDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method communitySectionDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onActiveChatChange*(self: AccessInterface, sectionId: string, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -1,5 +1,4 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/about/service as about_service
# import ./item as item
@ -7,23 +6,23 @@ import ../../../../../app_service/service/about/service as about_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
aboutService: about_service.ServiceInterface
proc newController*(delegate: io_interface.AccessInterface, aboutService: about_service.ServiceInterface): Controller =
result = Controller()
proc newController*[T](delegate: T, aboutService: about_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.aboutService = aboutService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getAppVersion*(self: Controller): string =
method getAppVersion*[T](self: Controller[T]): string =
return self.aboutService.getAppVersion()
method getNodeVersion*(self: Controller): string =
method getNodeVersion*[T](self: Controller[T]): string =
return self.aboutService.getNodeVersion()

View File

@ -17,8 +17,7 @@ method getAppVersion*(self: AccessInterface): string {.base.} =
method getNodeVersion*(self: AccessInterface): string {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/about/service as about_service
@ -9,38 +8,34 @@ import ../../../../../app_service/service/about/service as about_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, aboutService: about_service.ServiceInterface): Module =
result = Module()
proc newModule*[T](delegate: T, aboutService: about_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, aboutService)
result.controller = controller.newController[Module[T]](result, aboutService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("aboutModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
self.view.load()
method load*[T](self: Module[T]) =
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.aboutModuleDidLoad()
method getAppVersion*(self: Module): string =
method getAppVersion*[T](self: Module[T]): string =
return self.controller.getAppVersion()
method getNodeVersion*(self: Module): string =
method getNodeVersion*[T](self: Module[T]): string =
return self.controller.getNodeVersion()

View File

@ -16,9 +16,6 @@ QtObject:
result.QObject.setup
result.delegate = delegate
proc load*(self: View) =
self.delegate.viewDidLoad()
proc getCurrentVersion*(self: View): string {.slot.} =
return self.delegate.getAppVersion()

View File

@ -14,26 +14,26 @@ import eventemitter
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
events: EventEmitter
contactsService: contacts_service.Service
accountsService: accounts_service.ServiceInterface
proc newController*(delegate: io_interface.AccessInterface,
proc newController*[T](delegate: io_interface.AccessInterface,
events: EventEmitter,
contactsService: contacts_service.Service,
accountsService: accounts_service.ServiceInterface): Controller =
result = Controller()
accountsService: accounts_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.events = events
result.contactsService = contactsService
result.accountsService = accountsService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
self.events.on(SIGNAL_CONTACT_LOOKED_UP) do(e: Args):
var args = ContactArgs(e)
self.delegate.contactLookedUp(args.contactId)
@ -58,32 +58,32 @@ method init*(self: Controller) =
var args = ContactNicknameUpdatedArgs(e)
self.delegate.contactNicknameChanged(args.contactId, args.nickname)
method getContacts*(self: Controller): seq[ContactsDto] =
method getContacts*[T](self: Controller[T]): seq[ContactsDto] =
return self.contactsService.getContacts()
method getContact*(self: Controller, id: string): ContactsDto =
method getContact*[T](self: Controller[T], id: string): ContactsDto =
return self.contactsService.getContactById(id)
method generateAlias*(self: Controller, publicKey: string): string =
method generateAlias*[T](self: Controller[T], publicKey: string): string =
return self.accountsService.generateAlias(publicKey)
method addContact*(self: Controller, publicKey: string) =
method addContact*[T](self: Controller[T], publicKey: string) =
self.contactsService.addContact(publicKey)
method rejectContactRequest*(self: Controller, publicKey: string) =
method rejectContactRequest*[T](self: Controller[T], publicKey: string) =
self.contactsService.rejectContactRequest(publicKey)
method unblockContact*(self: Controller, publicKey: string) =
method unblockContact*[T](self: Controller[T], publicKey: string) =
self.contactsService.unblockContact(publicKey)
method blockContact*(self: Controller, publicKey: string) =
method blockContact*[T](self: Controller[T], publicKey: string) =
self.contactsService.blockContact(publicKey)
method removeContact*(self: Controller, publicKey: string) =
method removeContact*[T](self: Controller[T], publicKey: string) =
self.contactsService.removeContact(publicKey)
method changeContactNickname*(self: Controller, publicKey: string, nickname: string) =
method changeContactNickname*[T](self: Controller[T], publicKey: string, nickname: string) =
self.contactsService.changeContactNickname(publicKey, nickname)
method lookupContact*(self: Controller, value: string) =
method lookupContact*[T](self: Controller[T], value: string) =
self.contactsService.lookupContact(value)

View File

@ -64,8 +64,7 @@ method lookupContact*(self: AccessInterface, value: string) {.base.} =
method contactLookedUp*(self: AccessInterface, id: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import io_interface, view, controller, model
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/contacts/service as contacts_service
@ -13,97 +12,92 @@ import eventemitter
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface,
proc newModule*[T](delegate: T,
events: EventEmitter,
contactsService: contacts_service.Service,
accountsService: accounts_service.ServiceInterface):
Module =
result = Module()
Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, events, contactsService, accountsService)
result.controller = controller.newController[Module[T]](result, events, contactsService, accountsService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("contactsModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method setContactList*(self: Module, contacts: seq[ContactsDto]) =
method setContactList*[T](self: Module[T], contacts: seq[ContactsDto]) =
self.view.model().setContactList(contacts)
method updateContactList*(self: Module, contacts: seq[ContactsDto]) =
method updateContactList*[T](self: Module[T], contacts: seq[ContactsDto]) =
self.view.model().updateContactList(contacts)
method load*(self: Module) =
method load*[T](self: Module[T]) =
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
let contacts = self.controller.getContacts()
self.setContactList(contacts)
self.moduleLoaded = true
self.delegate.contactsModuleDidLoad()
method getContact*(self: Module, id: string): ContactsDto =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method getContact*[T](self: Module[T], id: string): ContactsDto =
self.controller.getContact(id)
method generateAlias*(self: Module, publicKey: string): string =
method generateAlias*[T](self: Module[T], publicKey: string): string =
self.controller.generateAlias(publicKey)
method addContact*(self: Module, publicKey: string) =
method addContact*[T](self: Module[T], publicKey: string) =
self.controller.addContact(publicKey)
method contactAdded*(self: Module, contact: ContactsDto) =
method contactAdded*[T](self: Module[T], contact: ContactsDto) =
self.view.model().contactAdded(contact)
method contactBlocked*(self: Module, publicKey: string) =
method contactBlocked*[T](self: Module[T], publicKey: string) =
# once we refactore a model, we should pass only pk from here (like we have for nickname change)
let contact = self.controller.getContact(publicKey)
self.view.model().contactBlocked(contact)
method contactUnblocked*(self: Module, publicKey: string) =
method contactUnblocked*[T](self: Module[T], publicKey: string) =
# once we refactore a model, we should pass only pk from here (like we have for nickname change)
let contact = self.controller.getContact(publicKey)
self.view.model().contactUnblocked(contact)
method contactRemoved*(self: Module, publicKey: string) =
method contactRemoved*[T](self: Module[T], publicKey: string) =
# once we refactore a model, we should pass only pk from here (like we have for nickname change)
let contact = self.controller.getContact(publicKey)
self.view.model().contactRemoved(contact)
method contactNicknameChanged*(self: Module, publicKey: string, nickname: string) =
method contactNicknameChanged*[T](self: Module[T], publicKey: string, nickname: string) =
self.view.model().changeNicknameForContactWithId(publicKey, nickname)
method rejectContactRequest*(self: Module, publicKey: string) =
method rejectContactRequest*[T](self: Module[T], publicKey: string) =
self.controller.rejectContactRequest(publicKey)
method unblockContact*(self: Module, publicKey: string) =
method unblockContact*[T](self: Module[T], publicKey: string) =
self.controller.unblockContact(publicKey)
method blockContact*(self: Module, publicKey: string) =
method blockContact*[T](self: Module[T], publicKey: string) =
self.controller.blockContact(publicKey)
method removeContact*(self: Module, publicKey: string) =
method removeContact*[T](self: Module[T], publicKey: string) =
self.controller.removeContact(publicKey)
method changeContactNickname*(self: Module, publicKey: string, nickname: string) =
method changeContactNickname*[T](self: Module[T], publicKey: string, nickname: string) =
self.controller.changeContactNickname(publicKey, nickname)
method lookupContact*(self: Module, value: string) =
method lookupContact*[T](self: Module[T], value: string) =
self.controller.lookupContact(value)
method contactLookedUp*(self: Module, id: string) =
method contactLookedUp*[T](self: Module[T], id: string) =
self.view.contactLookedUp(id)

View File

@ -33,9 +33,6 @@ QtObject:
result.modelVariant = newQVariant(result.model)
result.contactToAdd = ContactsDto()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc model*(self: View): Model =
return self.model

View File

@ -29,25 +29,6 @@ method toggleDebug*(self: AccessInterface) {.base.} =
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
# Methods called by submodules of this module
method profileModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method contactsModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method languageModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method mnemonicModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method privacyModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method aboutModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.

View File

@ -1,5 +1,4 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/language/service as language_service
# import ./item as item
@ -7,21 +6,17 @@ import ../../../../../app_service/service/language/service as language_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
languageService: language_service.ServiceInterface
method init*(self: Controller) =
discard
proc newController*(delegate: io_interface.AccessInterface, languageService: language_service.ServiceInterface):
Controller =
result = Controller()
proc newController*[T](delegate: T, languageService: language_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.languageService = languageService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method changeLanguage*(self: Controller, locale: string) =
method changeLanguage*[T](self: Controller[T], locale: string) =
self.languageService.setLanguage(locale)

View File

@ -14,8 +14,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method changeLanguage*(self: AccessInterface, locale: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/language/service as language_service
@ -9,36 +8,31 @@ import ../../../../../app_service/service/language/service as language_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, languageService: language_service.ServiceInterface): Module =
result = Module()
proc newModule*[T](delegate: T, languageService: language_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, languageService)
result.controller = controller.newController[Module[T]](result, languageService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("languageModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
self.controller.init()
self.view.load()
method load*[T](self: Module[T]) =
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.languageModuleDidLoad()
method changeLanguage*(self: Module, locale: string) =
method changeLanguage*[T](self: Module[T], locale: string) =
self.controller.changeLanguage(locale)

View File

@ -16,8 +16,5 @@ QtObject:
result.QObject.setup
result.delegate = delegate
proc load*(self: View) =
self.delegate.viewDidLoad()
proc changeLocale*(self: View, locale: string) {.slot.} =
self.delegate.changeLanguage(locale)

View File

@ -1,34 +1,32 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/mnemonic/service as mnemonic_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
mnemonicService: mnemonic_service.ServiceInterface
proc newController*(delegate: io_interface.AccessInterface, mnemonicService: mnemonic_service.ServiceInterface):
Controller =
result = Controller()
proc newController*[T](delegate: T, mnemonicService: mnemonic_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.mnemonicService = mnemonicService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method isBackedUp*(self: Controller): bool =
method isBackedUp*[T](self: Controller[T]): bool =
return self.mnemonicService.isBackedUp()
method getMnemonic*(self: Controller): string =
method getMnemonic*[T](self: Controller[T]): string =
return self.mnemonicService.getMnemonic()
method remove*(self: Controller) =
method remove*[T](self: Controller[T]) =
self.mnemonicService.remove()
method getWord*(self: Controller, index: int): string =
method getWord*[T](self: Controller[T], index: int): string =
return self.mnemonicService.getWord(index)

View File

@ -23,8 +23,7 @@ method remove*(self: AccessInterface) {.base.} =
method getWord*(self: AccessInterface, index: int): string {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/mnemonic/service as mnemonic_service
@ -9,45 +8,40 @@ import ../../../../../app_service/service/mnemonic/service as mnemonic_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, mnemonicService: mnemonic_service.ServiceInterface): Module =
result = Module()
proc newModule*[T](delegate: T, mnemonicService: mnemonic_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, mnemonicService)
result.controller = controller.newController[Module[T]](result, mnemonicService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("mnemonicModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
self.controller.init()
self.view.load()
method load*[T](self: Module[T]) =
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.mnemonicModuleDidLoad()
method isBackedUp*(self: Module): bool =
method isBackedUp*[T](self: Module[T]): bool =
return self.controller.isBackedup()
method getMnemonic*(self: Module): string =
method getMnemonic*[T](self: Module[T]): string =
return self.controller.getMnemonic()
method remove*(self: Module) =
method remove*[T](self: Module[T]) =
self.controller.remove()
method getWord*(self: Module, index: int): string =
method getWord*[T](self: Module[T], index: int): string =
return self.controller.getWord(index)

View File

@ -15,9 +15,6 @@ QtObject:
result.QObject.setup
result.delegate = delegate
proc load*(self: View) =
self.delegate.viewDidLoad()
proc isBackedUp*(self: View): bool {.slot.} =
return self.delegate.isBackedup()

View File

@ -78,7 +78,6 @@ method delete*[T](self: Module[T]) =
self.controller.delete
method load*[T](self: Module[T]) =
self.view.load()
self.profileModule.load()
self.contactsModule.load()
self.languageModule.load()
@ -86,32 +85,6 @@ method load*[T](self: Module[T]) =
self.privacyModule.load()
self.aboutModule.load()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
proc checkIfModuleDidLoad[T](self: Module[T]) =
if(not self.profileModule.isLoaded()):
return
if(not self.contactsModule.isLoaded()):
return
if(not self.languageModule.isLoaded()):
return
if(not self.mnemonicModule.isLoaded()):
return
if(not self.privacyModule.isLoaded()):
return
if(not self.aboutModule.isLoaded()):
return
self.moduleLoaded = true
self.delegate.profileSectionDidLoad()
method viewDidLoad*[T](self: Module[T]) =
self.view.setIsTelemetryEnabled(self.controller.isTelemetryEnabled())
self.view.setIsDebugEnabled(self.controller.isDebugEnabled())
self.view.setIsAutoMessageEnabled(self.controller.isAutoMessageEnabled())
@ -126,14 +99,14 @@ method contactsModuleDidLoad*[T](self: Module[T]) =
method languageModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method mnemonicModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
self.moduleLoaded = true
self.delegate.profileSectionDidLoad()
method privacyModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method aboutModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method viewDidLoad*(self: Module) =
discard
method enableDeveloperFeatures*[T](self: Module[T]) =
self.controller.enableDeveloperFeatures()

View File

@ -1,32 +1,30 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/accounts/service as accounts_service
import ../../../../../app_service/service/privacy/service as privacy_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
accountsService: accounts_service.ServiceInterface
privacyService: privacy_service.ServiceInterface
proc newController*(delegate: io_interface.AccessInterface, privacyService: privacy_service.ServiceInterface,
accountsService: accounts_service.ServiceInterface): Controller =
result = Controller()
proc newController*[T](delegate: T, privacyService: privacy_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.accountsService = accountsService
result.privacyService = privacyService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getLinkPreviewWhitelist*(self: Controller): string =
method getLinkPreviewWhitelist*[T](self: Controller[T]): string =
return self.privacyService.getLinkPreviewWhitelist()
method changePassword*(self: Controller, password: string, newPassword: string): bool =
method changePassword*[T](self: Controller[T], password: string, newPassword: string): bool =
let loggedInAccount = self.accountsService.getLoggedInAccount()
return self.privacyService.changePassword(loggedInAccount.keyUid, password, newPassword)

View File

@ -17,8 +17,7 @@ method getLinkPreviewWhitelist*(self: AccessInterface): string {.base.} =
method changePassword*(self: AccessInterface, password: string, newPassword: string): bool {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/accounts/service as accounts_service
@ -10,39 +9,34 @@ import ../../../../../app_service/service/privacy/service as privacy_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, privacyService: privacy_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Module =
result = Module()
proc newModule*[T](delegate: T, privacyService: privacy_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, privacyService, accountsService)
result.controller = controller.newController[Module[T]](result, privacyService, accountsService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("privacyModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
self.controller.init()
self.view.load()
method load*[T](self: Module[T]) =
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.privacyModuleDidLoad()
method getLinkPreviewWhitelist*(self: Module): string =
method getLinkPreviewWhitelist*[T](self: Module[T]): string =
return self.controller.getLinkPreviewWhitelist()
method changePassword*(self: Module, password: string, newPassword: string): bool =
method changePassword*[T](self: Module[T], password: string, newPassword: string): bool =
return self.controller.changePassword(password, newPassword)

View File

@ -16,9 +16,6 @@ QtObject:
result.QObject.setup
result.delegate = delegate
proc load*(self: View) =
self.delegate.viewDidLoad()
proc getLinkPreviewWhitelist*(self: View): string {.slot.} =
return self.delegate.getLinkPreviewWhitelist()

View File

@ -1,5 +1,5 @@
import ./controller_interface
import io_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/profile/service as profile_service
import ../../../../../app_service/service/accounts/service as accounts_service
@ -11,27 +11,27 @@ import status/types/identity_image
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
profileService: profile_service.ServiceInterface
settingsService: settings_service.ServiceInterface
accountsService: accounts_service.ServiceInterface
proc newController*(delegate: io_interface.AccessInterface, accountsService: accounts_service.ServiceInterface,
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Controller =
result = Controller()
proc newController*[T](delegate: T, accountsService: accounts_service.ServiceInterface,
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.profileService = profileService
result.settingsService = settingsService
result.accountsService = accountsService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getProfile*(self: Controller): item.Item =
method getProfile*[T](self: Controller[T]): item.Item =
var appearance = self.settingsService.getAppearance()
var messagesFromContactsOnly = self.settingsService.getMessagesFromContactsOnly()
@ -60,12 +60,12 @@ method getProfile*(self: Controller): item.Item =
return item
method storeIdentityImage*(self: Controller, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
method storeIdentityImage*[T](self: Controller[T], address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
result = self.profileService.storeIdentityImage(address, image, aX, aY, bX, bY)
singletonInstance.userProfile.setThumbnailImage(result.thumbnail)
singletonInstance.userProfile.setLargeImage(result.large)
method deleteIdentityImage*(self: Controller, address: string): string =
method deleteIdentityImage*[T](self: Controller[T], address: string): string =
result = self.profileService.deleteIdentityImage(address)
singletonInstance.userProfile.setThumbnailImage("")
singletonInstance.userProfile.setLargeImage("")

View File

@ -13,15 +13,13 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method storeIdentityImage*(self: AccessInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int):
identity_image.IdentityImage {.base.} =
method storeIdentityImage*(self: AccessInterface, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage {.base.} =
raise newException(ValueError, "No implementation available")
method deleteIdentityImage*(self: AccessInterface, address: string): string {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, Tables
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/profile/service as profile_service
@ -13,43 +12,37 @@ import status/types/identity_image
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
controller: controller.AccessInterface
view: View
viewVariant: QVariant
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, accountsService: accounts_service.ServiceInterface,
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Module =
result = Module()
proc newModule*[T](delegate: T, accountsService: accounts_service.ServiceInterface,
settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, accountsService, settingsService, profileService)
result.controller = controller.newController[Module[T]](result, accountsService, settingsService, profileService)
result.moduleLoaded = false
singletonInstance.engine.setRootContextProperty("profileModule", result.viewVariant)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
method load*[T](self: Module[T]) =
let profile = self.controller.getProfile()
self.view.setProfile(profile)
self.moduleLoaded = true
self.delegate.profileModuleDidLoad()
method storeIdentityImage*(self: Module, address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method storeIdentityImage*[T](self: Module[T], address: string, image: string, aX: int, aY: int, bX: int, bY: int): identity_image.IdentityImage =
self.controller.storeIdentityImage(address, image, aX, aY, bX, bY)
method deleteIdentityImage*(self: Module, address: string): string =
method deleteIdentityImage*[T](self: Module[T], address: string): string =
self.controller.deleteIdentityImage(address)

View File

@ -28,9 +28,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel*(self: View): QVariant {.slot.} =

View File

@ -22,9 +22,6 @@ QtObject:
result.delegate = delegate
result.setup()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc isTelemetryEnabledChanged*(self: View) {.signal.}
proc setIsTelemetryEnabled*(self: View, isTelemetryEnabled: bool) =

View File

@ -15,9 +15,6 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method buy*(self: AccessInterface, packId: int, address: string, price: string, gas: string, gasPrice: string, maxPriorityFeePerGas: string, maxFeePerGas: string, password: string): tuple[response: string, success: bool] {.base.} =
raise newException(ValueError, "No implementation available")
@ -70,4 +67,3 @@ type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c
c.stickersDidLoad()

View File

@ -34,15 +34,11 @@ method delete*[T](self: Module[T]) =
method load*[T](self: Module[T]) =
self.controller.init()
self.view.load()
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*[T](self: Module[T]) =
self.moduleLoaded = true
self.delegate.stickersDidLoad()
method buy*[T](self: Module[T], packId: int, address: string, price: string, gas: string, gasPrice: string, maxPriorityFeePerGas: string, maxFeePerGas: string, password: string): tuple[response: string, success: bool] =
return self.controller.buy(packId, address, price, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password)

View File

@ -22,9 +22,6 @@ QtObject:
result.stickerPacks = newStickerPackList()
result.recentStickers = newStickerList()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc addStickerPackToList*(self: View, stickerPack: StickerPackDto, isInstalled, isBought, isPending: bool) =
self.stickerPacks.addStickerPackToList(stickerPack, newStickerList(stickerPack.stickers), isInstalled, isBought, isPending)

View File

@ -1,27 +1,26 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
walletAccountService: wallet_account_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
walletAccountService: wallet_account_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
method getWalletAccount*[T](self: Controller[T], accountIndex: int): wallet_account_service.WalletAccountDto =
return self.walletAccountService.getWalletAccount(accountIndex)

View File

@ -14,8 +14,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,37 +1,36 @@
import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
events: EventEmitter
view: View
moduleLoaded: bool
controller: controller.AccessInterface
currentAccountIndex: int
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
walletAccountService: wallet_account_service.ServiceInterface
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.events = events
result.view = newView(result)
result.controller = newController(result, walletAccountService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method switchAccount*(self: Module, accountIndex: int) =
method switchAccount*[T](self: Module[T], accountIndex: int) =
self.currentAccountIndex = accountIndex
let walletAccount = self.controller.getWalletAccount(accountIndex)
self.view.setItems(
@ -44,22 +43,15 @@ method switchAccount*(self: Module, accountIndex: int) =
))
)
method load*(self: Module) =
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("walletSectionAccountTokens", newQVariant(self.view))
# these connections should be part of the controller's init method
self.events.on("walletAccount/currencyUpdated") do(e:Args):
self.switchAccount(self.currentAccountIndex)
self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args):
self.switchAccount(self.currentAccountIndex)
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.accountTokensModuleDidLoad()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded

View File

@ -22,9 +22,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel(self: View): QVariant {.slot.} =

View File

@ -1,42 +1,41 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
walletAccountService: wallet_account_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
walletAccountService: wallet_account_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
method getWalletAccounts*[T](self: Controller[T]): seq[wallet_account_service.WalletAccountDto] =
return self.walletAccountService.getWalletAccounts()
method generateNewAccount*(self: Controller, password: string, accountName: string, color: string): string =
method generateNewAccount*[T](self: Controller[T], password: string, accountName: string, color: string): string =
return self.walletAccountService.generateNewAccount(password, accountName, color)
method addAccountsFromPrivateKey*(self: Controller, privateKey: string, password: string, accountName: string, color: string): string =
method addAccountsFromPrivateKey*[T](self: Controller[T], privateKey: string, password: string, accountName: string, color: string): string =
return self.walletAccountService.addAccountsFromPrivateKey(privateKey, password, accountName, color)
method addAccountsFromSeed*(self: Controller, seedPhrase: string, password: string, accountName: string, color: string): string =
method addAccountsFromSeed*[T](self: Controller[T], seedPhrase: string, password: string, accountName: string, color: string): string =
return self.walletAccountService.addAccountsFromSeed(seedPhrase, password, accountName, color)
method addWatchOnlyAccount*(self: Controller, address: string, accountName: string, color: string): string =
method addWatchOnlyAccount*[T](self: Controller[T], address: string, accountName: string, color: string): string =
return self.walletAccountService.addWatchOnlyAccount(address, accountName, color)
method deleteAccount*(self: Controller, address: string) =
method deleteAccount*[T](self: Controller[T], address: string) =
self.walletAccountService.deleteAccount(address)

View File

@ -29,9 +29,8 @@ method deleteAccount*(self: AccessInterface, address: string) {.base.} =
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -2,7 +2,6 @@ import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./item, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
import ../account_tokens/model as account_tokens
@ -11,34 +10,34 @@ import ../account_tokens/item as account_tokens_item
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
events: EventEmitter
view: View
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
walletAccountService: wallet_account_service.ServiceInterface,
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.events = events
result.view = newView(result)
result.controller = controller.newController(result, walletAccountService)
result.controller = controller.newController[Module[T]](result, walletAccountService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method refreshWalletAccounts*(self: Module) =
method refreshWalletAccounts*[T](self: Module[T]) =
let walletAccounts = self.controller.getWalletAccounts()
let items = walletAccounts.map(proc (w: WalletAccountDto): item.Item =
let items = walletAccounts.map(proc (w: WalletAccountDto): Item =
let assets = account_tokens.newModel()
@ -67,10 +66,8 @@ method refreshWalletAccounts*(self: Module) =
self.view.setItems(items)
method load*(self: Module) =
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("walletSectionAccounts", newQVariant(self.view))
# these connections should be part of the controller's init method
self.events.on("walletAccount/accountSaved") do(e:Args):
self.refreshWalletAccounts()
@ -86,28 +83,23 @@ method load*(self: Module) =
self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args):
self.refreshWalletAccounts()
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.refreshWalletAccounts()
self.moduleLoaded = true
self.delegate.accountsModuleDidLoad()
method generateNewAccount*(self: Module, password: string, accountName: string, color: string): string =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method generateNewAccount*[T](self: Module[T], password: string, accountName: string, color: string): string =
return self.controller.generateNewAccount(password, accountName, color)
method addAccountsFromPrivateKey*(self: Module, privateKey: string, password: string, accountName: string, color: string): string =
method addAccountsFromPrivateKey*[T](self: Module[T], privateKey: string, password: string, accountName: string, color: string): string =
return self.controller.addAccountsFromPrivateKey(privateKey, password, accountName, color)
method addAccountsFromSeed*(self: Module, seedPhrase: string, password: string, accountName: string, color: string): string =
method addAccountsFromSeed*[T](self: Module[T], seedPhrase: string, password: string, accountName: string, color: string): string =
return self.controller.addAccountsFromSeed(seedPhrase, password, accountName, color)
method addWatchOnlyAccount*(self: Module, address: string, accountName: string, color: string): string =
method addWatchOnlyAccount*[T](self: Module[T], address: string, accountName: string, color: string): string =
return self.controller.addWatchOnlyAccount(address, accountName, color)
method deleteAccount*(self: Module, address: string) =
method deleteAccount*[T](self: Module[T], address: string) =
self.controller.deleteAccount(address)

View File

@ -23,9 +23,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel(self: View): QVariant {.slot.} =

View File

@ -7,43 +7,43 @@ import ../../../../../app_service/service/wallet_account/service as wallet_accou
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
events: EventEmitter
tokenService: token_service.Service
walletAccountService: wallet_account_service.ServiceInterface
proc newController*(
proc newController*[T](
delegate: io_interface.AccessInterface,
events: EventEmitter,
tokenService: token_service.Service,
walletAccountService: wallet_account_service.ServiceInterface,
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.events = events
result.delegate = delegate
result.tokenService = tokenService
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
self.events.on(SIGNAL_TOKEN_DETAILS_LOADED) do(e:Args):
let args = TokenDetailsLoadedArgs(e)
self.delegate.tokenDetailsWereResolved(args.tokenDetails)
method getTokens*(self: Controller): seq[token_service.TokenDto] =
method getTokens*[T](self: Controller[T]): seq[token_service.TokenDto] =
return self.tokenService.getTokens()
method addCustomToken*(self: Controller, address: string, name: string, symbol: string, decimals: int) =
method addCustomToken*[T](self: Controller[T], address: string, name: string, symbol: string, decimals: int) =
self.tokenService.addCustomToken(address, name, symbol, decimals)
method toggleVisible*(self: Controller, symbol: string) =
method toggleVisible*[T](self: Controller[T], symbol: string) =
self.walletAccountService.toggleTokenVisible(symbol)
method removeCustomToken*(self: Controller, address: string) =
method removeCustomToken*[T](self: Controller[T], address: string) =
self.tokenService.removeCustomToken(address)
method getTokenDetails*(self: Controller, address: string) =
method getTokenDetails*[T](self: Controller[T], address: string) =
self.tokenService.getTokenDetails(address)

View File

@ -29,8 +29,7 @@ method getTokenDetails*(self: AccessInterface, address: string) {.base.} =
method tokenDetailsWereResolved*(self: AccessInterface, tokenDetails: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -3,7 +3,6 @@ import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/token/service as token_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
@ -11,31 +10,31 @@ import ../../../../../app_service/service/wallet_account/service as wallet_accou
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
events: EventEmitter
view: View
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
tokenService: token_service.Service,
walletAccountService: wallet_account_service.ServiceInterface,
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.events = events
result.view = newView(result)
result.controller = controller.newController(result, events, tokenService, walletAccountService)
result.controller = controller.newController[Module[T]](result, events, tokenService, walletAccountService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method refreshTokens*(self: Module) =
method refreshTokens*[T](self: Module[T]) =
let tokens = self.controller.getTokens()
self.view.setItems(
tokens.map(t => initItem(
@ -49,10 +48,11 @@ method refreshTokens*(self: Module) =
))
)
method load*(self: Module) =
method load*[T](self: Module[T]) =
self.controller.init()
singletonInstance.engine.setRootContextProperty("walletSectionAllTokens", newQVariant(self.view))
self.refreshTokens()
# these connections should be part of the controller's init method
self.events.on("token/customTokenAdded") do(e:Args):
self.refreshTokens()
@ -62,28 +62,22 @@ method load*(self: Module) =
self.events.on("token/customTokenRemoved") do(e:Args):
self.refreshTokens()
self.controller.init()
self.view.load()
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.refreshTokens()
self.moduleLoaded = true
self.delegate.allTokensModuleDidLoad()
method addCustomToken*(self: Module, address: string, name: string, symbol: string, decimals: int) =
method addCustomToken*[T](self: Module[T], address: string, name: string, symbol: string, decimals: int) =
self.controller.addCustomToken(address, name, symbol, decimals)
method toggleVisible*(self: Module, symbol: string) =
method toggleVisible*[T](self: Module[T], symbol: string) =
self.controller.toggleVisible(symbol)
method removeCustomToken*(self: Module, address: string) =
method removeCustomToken*[T](self: Module[T], address: string) =
self.controller.removeCustomToken(address)
method getTokenDetails*(self: Module, address: string) =
method getTokenDetails*[T](self: Module[T], address: string) =
self.controller.getTokenDetails(address)
method tokenDetailsWereResolved*(self: Module, tokenDetails: string) =
method tokenDetailsWereResolved*[T](self: Module[T], tokenDetails: string) =
self.view.tokenDetailsWereResolved(tokenDetails)

View File

@ -26,9 +26,6 @@ QtObject:
result.custom = newModel()
result.all = newModel()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc allChanged*(self: View) {.signal.}
proc getAll(self: View): QVariant {.slot.} =

View File

@ -1,24 +1,23 @@
import ./controller_interface
import io_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
collectibleService: collectible_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
collectibleService: collectible_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.collectibleService = collectibleService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard

View File

@ -11,8 +11,7 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,37 +1,30 @@
import sequtils, sugar
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
view: View
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, collectibleService: collectible_service.ServiceInterface):
Module =
result = Module()
proc newModule*[T](delegate: T, collectibleService: collectible_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.controller = controller.newController(result, collectibleService)
result.controller = controller.newController[Module[T]](result, collectibleService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method load*(self: Module) =
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
method load*[T](self: Module[T]) =
self.moduleLoaded = true
self.delegate.collectibleModuleDidLoad()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded

View File

@ -23,9 +23,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel(self: View): QVariant {.slot.} =

View File

@ -1,27 +1,26 @@
import ./controller_interface
import io_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
collectibleService: collectible_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
collectibleService: collectible_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.collectibleService = collectibleService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method fetch*(self: Controller, address: string, collectionSlug: string): seq[collectible_service.CollectibleDto] =
method fetch*[T](self: Controller[T], address: string, collectionSlug: string): seq[collectible_service.CollectibleDto] =
return self.collectible_service.getCollectibles(address, collectionSlug)

View File

@ -17,8 +17,7 @@ method fetch*(self: AccessInterface, collectionSlug: string) {.base.} =
method setCurrentAddress*(self: AccessInterface, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -2,47 +2,42 @@ import sequtils, sugar, NimQml
import ../../../../../global/global_singleton
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
view: View
controller: controller.AccessInterface
moduleLoaded: bool
currentAddress: string
proc newModule*(delegate: delegate_interface.AccessInterface, collectibleService: collectible_service.ServiceInterface):
Module =
result = Module()
proc newModule*[T](delegate: T, collectibleService: collectible_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.controller = controller.newController(result, collectibleService)
result.controller = controller.newController[Module[T]](result, collectibleService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("walletSectionCollectiblesCollectibles", newQVariant(self.view))
self.controller.init()
self.view.load()
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty(
"walletSectionCollectiblesCollectibles", newQVariant(self.view)
)
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.collectiblesModuleDidLoad()
method setCurrentAddress*(self: Module, address: string) =
method setCurrentAddress*[T](self: Module[T], address: string) =
self.currentAddress = address
method fetch*(self: Module, collectionSlug: string) =
method fetch*[T](self: Module[T], collectionSlug: string) =
let collectibles = self.controller.fetch(self.currentAddress, collectionSlug)
let items = collectibles.map(c => initItem(
c.id,

View File

@ -19,9 +19,6 @@ QtObject:
result.delegate = delegate
result.models = initTable[string, Model]()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc setItems*(self: View, collectionSlug: string, items: seq[Item]) =
if not self.models.hasKey(collectionSlug):
self.models[collectionSlug] = newModel()

View File

@ -1,27 +1,26 @@
import ./controller_interface
import io_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
collectibleService: collectible_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
collectibleService: collectible_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.collectibleService = collectibleService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getCollections*(self: Controller, address: string): seq[collectible_service.CollectionDto] =
method getCollections*[T](self: Controller[T], address: string): seq[collectible_service.CollectionDto] =
return self.collectibleService.getCollections(address)

View File

@ -14,8 +14,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method loadCollections*(self: AccessInterface, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -2,43 +2,38 @@ import NimQml, sequtils, sugar
import ../../../../../global/global_singleton
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../../../app_service/service/collectible/service as collectible_service
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
view: View
controller: controller.AccessInterface
moduleLoaded: bool
proc newModule*(delegate: delegate_interface.AccessInterface, collectibleService: collectible_service.ServiceInterface):
Module =
result = Module()
proc newModule*[T](delegate: T, collectibleService: collectible_service.ServiceInterface): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.controller = controller.newController(result, collectibleService)
result.controller = controller.newController[Module[T]](result, collectibleService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("walletSectionCollectiblesCollections", newQVariant(self.view))
self.controller.init()
self.view.load()
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty(
"walletSectionCollectiblesCollections", newQVariant(self.view)
)
self.moduleLoaded = true
method isLoaded*(self: Module): bool =
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.collectionsModuleDidLoad()
method loadCollections*(self: Module, address: string) =
method loadCollections*[T](self: Module[T], address: string) =
let collections = self.controller.getCollections(address)
self.view.setItems(
collections.map(c => initItem(

View File

@ -23,9 +23,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel(self: View): QVariant {.slot.} =

View File

@ -1,27 +1,26 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
walletAccountService: wallet_account_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
walletAccountService: wallet_account_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
method getWalletAccount*[T](self: Controller[T], accountIndex: int): wallet_account_service.WalletAccountDto =
return self.walletAccountService.getWalletAccount(accountIndex)

View File

@ -14,12 +14,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
raise newException(ValueError, "No implementation available")
# Methods called by submodules of this module
method collectibleModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method collectiblesModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method collectionsModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import eventemitter
import ./io_interface, ./controller
import ../io_interface as delegate_interface
import ../../../../../app_service/service/collectible/service as collectible_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
@ -12,8 +11,8 @@ import ./collectibles/module as collectibles_module
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
moduleLoaded: bool
controller: controller.AccessInterface
@ -21,58 +20,43 @@ type
collectionsModule: collections_module.AccessInterface
collectibleModule: collectible_module.AccessInterface
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
collectibleService: collectible_service.ServiceInterface,
walletAccountService: wallet_account_service.ServiceInterface
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.controller = newController(result, walletAccountService)
result.moduleLoaded = false
result.collectiblesModule = collectibles_module.newModule(result, collectibleService)
result.collectionsModule = collectionsModule.newModule(result, collectibleService)
result.collectibleModule = collectibleModule.newModule(result, collectibleService)
result.collectiblesModule = collectibles_module.newModule[Module[T]](
result, collectibleService
)
result.collectionsModule = collectionsModule.newModule[Module[T]](
result, collectibleService
)
result.collectibleModule = collectibleModule.newModule[Module[T]](
result, collectibleService
)
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.collectiblesModule.delete
self.collectionsModule.delete
self.collectibleModule.delete
method load*(self: Module) =
self.controller.init
method load*[T](self: Module[T]) =
self.collectiblesModule.load
self.collectionsModule.load
self.collectibleModule.load
method isLoaded*(self: Module): bool =
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
proc checkIfModuleDidLoad(self: Module) =
if(not self.collectiblesModule.isLoaded()):
return
if(not self.collectionsModule.isLoaded()):
return
if(not self.collectibleModule.isLoaded()):
return
self.moduleLoaded = true
self.delegate.collectiblesModuleDidLoad()
method collectibleModuleDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method collectiblesModuleDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method collectionsModuleDidLoad*(self: Module) =
self.checkIfModuleDidLoad()
method switchAccount*(self: Module, accountIndex: int) =
method switchAccount*[T](self: Module[T], accountIndex: int) =
let account = self.controller.getWalletAccount(accountIndex)
self.collectionsModule.loadCollections(account.address)
self.collectiblesModule.setCurrentAddress(account.address)

View File

@ -1,30 +1,29 @@
import ./controller_interface
import io_interface
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export controller_interface
type
Controller* = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: T
walletAccountService: wallet_account_service.ServiceInterface
proc newController*(
delegate: io_interface.AccessInterface,
proc newController*[T](
delegate: T,
walletAccountService: wallet_account_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
discard
method getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
method getWalletAccount*[T](self: Controller[T], accountIndex: int): wallet_account_service.WalletAccountDto =
return self.walletAccountService.getWalletAccount(accountIndex)
method update*(self: Controller, address: string, accountName: string, color: string) =
method update*[T](self: Controller[T], address: string, accountName: string, color: string) =
self.walletAccountService.updateWalletAccount(address, accountName, color)

View File

@ -17,8 +17,7 @@ method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
method update*(self: AccessInterface, address: string, accountName: string, color: string) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -4,25 +4,24 @@ import ../../../../global/global_singleton
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
events: EventEmitter
view: View
controller: controller.AccessInterface
moduleLoaded: bool
currentAccountIndex: int
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
walletAccountService: wallet_account_service.ServiceInterface,
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.events = events
result.currentAccountIndex = 0
@ -30,13 +29,12 @@ proc newModule*(
result.controller = newController(result, walletAccountService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
method load*(self: Module) =
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("walletSectionCurrent", newQVariant(self.view))
# these connections should be part of the controller's init method
self.events.on("walletAccount/walletAccountUpdated") do(e:Args):
self.switchAccount(self.currentAccountIndex)
@ -46,20 +44,16 @@ method load*(self: Module) =
self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args):
self.switchAccount(self.currentAccountIndex)
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.currentAccountModuleDidLoad()
method switchAccount*(self: Module, accountIndex: int) =
method switchAccount*[T](self: Module[T], accountIndex: int) =
self.currentAccountIndex = accountIndex
let walletAccount = self.controller.getWalletAccount(accountIndex)
self.view.setData(walletAccount)
method update*(self: Module, address: string, accountName: string, color: string) =
method update*[T](self: Module[T], address: string, accountName: string, color: string) =
self.controller.update(address, accountName, color)

View File

@ -30,9 +30,6 @@ QtObject:
result.delegate = delegate
result.setup()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc getName(self: View): QVariant {.slot.} =
return newQVariant(self.name)

View File

@ -19,32 +19,6 @@ method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
method setTotalCurrencyBalance*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
# Methods called by submodules of this module
method accountTokensModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method accountsModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method allTokensModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method collectiblesModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method currentAccountModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method transactionsModuleDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.

View File

@ -53,12 +53,12 @@ proc newModule*[T](
result.controller = newController(result, settingsService, walletAccountService)
result.view = newView(result)
result.accountTokensModule = account_tokens_module.newModule(result, events, walletAccountService)
result.accountsModule = accounts_module.newModule(result, events, walletAccountService)
result.allTokensModule = all_tokens_module.newModule(result, events, tokenService, walletAccountService)
result.collectiblesModule = collectibles_module.newModule(result, events, collectibleService, walletAccountService)
result.currentAccountModule = current_account_module.newModule(result, events, walletAccountService)
result.transactionsModule = transactions_module.newModule(result, events, transactionService, walletAccountService)
result.accountTokensModule = account_tokens_module.newModule[Module[T]](result, events, walletAccountService)
result.accountsModule = accounts_module.newModule[io_interface.AccessInterface](result, events, walletAccountService)
result.allTokensModule = all_tokens_module.newModule[Module[T]](result, events, tokenService, walletAccountService)
result.collectiblesModule = collectibles_module.newModule[Module[T]](result, events, collectibleService, walletAccountService)
result.currentAccountModule = current_account_module.newModule[Module[T]](result, events, walletAccountService)
result.transactionsModule = transactions_module.newModule[Module[T]](result, events, transactionService, walletAccountService)
method delete*[T](self: Module[T]) =
self.accountTokensModule.delete
@ -94,8 +94,6 @@ method load*[T](self: Module[T]) =
self.events.on("walletAccount/tokenVisibilityToggled") do(e:Args):
self.setTotalCurrencyBalance()
self.controller.init()
self.view.load()
self.accountTokensModule.load()
self.accountsModule.load()
self.allTokensModule.load()
@ -103,55 +101,15 @@ method load*[T](self: Module[T]) =
self.currentAccountModule.load()
self.transactionsModule.load()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
proc checkIfModuleDidLoad[T](self: Module[T]) =
if(not self.accountTokensModule.isLoaded()):
return
if(not self.accountsModule.isLoaded()):
return
if(not self.allTokensModule.isLoaded()):
return
if(not self.collectiblesModule.isLoaded()):
return
if(not self.currentAccountModule.isLoaded()):
return
if(not self.transactionsModule.isLoaded()):
return
self.switchAccount(0)
let currency = self.controller.getCurrency()
let signingPhrase = self.controller.getSigningPhrase()
let mnemonicBackedUp = self.controller.isMnemonicBackedUp()
self.view.setData(currency, signingPhrase, mnemonicBackedUp)
self.setTotalCurrencyBalance()
self.moduleLoaded = true
self.delegate.walletSectionDidLoad()
method viewDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method accountTokensModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method accountsModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method allTokensModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method collectiblesModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method currentAccountModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()
method transactionsModuleDidLoad*[T](self: Module[T]) =
self.checkIfModuleDidLoad()

View File

@ -15,32 +15,32 @@ import ../../../../core/[main]
import ../../../../core/tasks/[qt, threadpool]
type
Controller* = ref object of controller_interface.AccessInterface
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
delegate: io_interface.AccessInterface
events: EventEmitter
transactionService: transaction_service.Service
walletAccountService: wallet_account_service.ServiceInterface
# Forward declaration
method loadTransactions*(self: Controller, address: string, toBlock: Uint256, limit: int = 20, loadMore: bool = false)
method getWalletAccounts*(self: Controller): seq[WalletAccountDto]
method loadTransactions*[T](self: Controller[T], address: string, toBlock: Uint256, limit: int = 20, loadMore: bool = false)
method getWalletAccounts*[T](self: Controller[T]): seq[WalletAccountDto]
proc newController*(
proc newController*[T](
delegate: io_interface.AccessInterface,
events: EventEmitter,
transactionService: transaction_service.Service,
walletAccountService: wallet_account_service.ServiceInterface
): Controller =
result = Controller()
): Controller[T] =
result = Controller[T]()
result.events = events
result.delegate = delegate
result.transactionService = transactionService
result.walletAccountService = walletAccountService
method delete*(self: Controller) =
method delete*[T](self: Controller[T]) =
discard
method init*(self: Controller) =
method init*[T](self: Controller[T]) =
self.events.on(SignalType.Wallet.event) do(e:Args):
var data = WalletSignal(e)
case data.eventType:
@ -66,17 +66,17 @@ method init*(self: Controller) =
let args = TransactionsLoadedArgs(e)
self.delegate.setTrxHistoryResult(args.transactions, args.address, args.wasFetchMore)
method checkRecentHistory*(self: Controller) =
method checkRecentHistory*[T](self: Controller[T]) =
self.transactionService.checkRecentHistory()
method getWalletAccounts*(self: Controller): seq[WalletAccountDto] =
method getWalletAccounts*[T](self: Controller[T]): seq[WalletAccountDto] =
self.walletAccountService.getWalletAccounts()
method getWalletAccount*(self: Controller, accountIndex: int): WalletAccountDto =
method getWalletAccount*[T](self: Controller[T], accountIndex: int): WalletAccountDto =
return self.walletAccountService.getWalletAccount(accountIndex)
method getAccountByAddress*(self: Controller, address: string): WalletAccountDto =
method getAccountByAddress*[T](self: Controller[T], address: string): WalletAccountDto =
self.walletAccountService.getAccountByAddress(address)
method loadTransactions*(self: Controller, address: string, toBlock: Uint256, limit: int = 20, loadMore: bool = false) =
method loadTransactions*[T](self: Controller[T], address: string, toBlock: Uint256, limit: int = 20, loadMore: bool = false) =
self.transactionService.loadTransactions(address, toBlock, limit, loadMore)

View File

@ -37,8 +37,7 @@ method setTrxHistoryResult*(self: AccessInterface, transactions: seq[Transaction
method setHistoryFetchState*(self: AccessInterface, addresses: seq[string], isFetching: bool) {.base.} =
raise newException(ValueError, "No implementation available")
# View Delegate Interface
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.
DelegateInterface* = concept c

View File

@ -1,7 +1,6 @@
import NimQml, eventemitter, stint
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../../app_service/service/transaction/service as transaction_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
@ -9,62 +8,61 @@ import ../../../../../app_service/service/wallet_account/service as wallet_accou
export io_interface
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
delegate: T
view: View
controller: controller.AccessInterface
moduleLoaded: bool
# Forward declarations
method checkRecentHistory*(self: Module)
method getWalletAccounts*(self: Module): seq[WalletAccountDto]
method loadTransactions*(self: Module, address: string, toBlock: string = "0x0", limit: int = 20, loadMore: bool = false)
method checkRecentHistory*[T](self: Module[T])
method getWalletAccounts*[T](self: Module[T]): seq[WalletAccountDto]
method loadTransactions*[T](self: Module[T], address: string, toBlock: string = "0x0", limit: int = 20, loadMore: bool = false)
proc newModule*(
delegate: delegate_interface.AccessInterface,
proc newModule*[T](
delegate: T,
events: EventEmitter,
transactionService: transaction_service.Service,
walletAccountService: wallet_account_service.ServiceInterface
): Module =
result = Module()
): Module[T] =
result = Module[T]()
result.delegate = delegate
result.view = newView(result)
result.controller = controller.newController(result, events, transactionService, walletAccountService)
result.controller = controller.newController[Module[T]](result, events, transactionService, walletAccountService)
result.moduleLoaded = false
method delete*(self: Module) =
method delete*[T](self: Module[T]) =
self.view.delete
self.controller.delete
method load*(self: Module) =
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("walletSectionTransactions", newQVariant(self.view))
self.controller.init()
self.view.load()
method isLoaded*(self: Module): bool =
return self.moduleLoaded
method viewDidLoad*(self: Module) =
self.checkRecentHistory()
let accounts = self.getWalletAccounts()
self.moduleLoaded = true
self.delegate.transactionsModuleDidLoad()
self.controller.init()
method switchAccount*(self: Module, accountIndex: int) =
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method switchAccount*[T](self: Module[T], accountIndex: int) =
let walletAccount = self.controller.getWalletAccount(accountIndex)
self.view.switchAccount(walletAccount)
method checkRecentHistory*(self: Module) =
method checkRecentHistory*[T](self: Module[T]) =
self.controller.checkRecentHistory()
method getWalletAccounts*(self: Module): seq[WalletAccountDto] =
method getWalletAccounts*[T](self: Module[T]): seq[WalletAccountDto] =
self.controller.getWalletAccounts()
method getAccountByAddress*(self: Module, address: string): WalletAccountDto =
method getAccountByAddress*[T](self: Module[T], address: string): WalletAccountDto =
self.controller.getAccountByAddress(address)
method loadTransactions*(self: Module, address: string, toBlock: string = "0x0", limit: int = 20, loadMore: bool = false) =
method loadTransactions*[T](self: Module[T], address: string, toBlock: string = "0x0", limit: int = 20, loadMore: bool = false) =
let toBlockParsed = stint.fromHex(Uint256, toBlock)
let txLimit = if toBlock == "0x0":
limit
@ -73,10 +71,10 @@ method loadTransactions*(self: Module, address: string, toBlock: string = "0x0",
self.controller.loadTransactions(address, toBlockParsed, txLimit, loadMore)
method setTrxHistoryResult*(self: Module, transactions: seq[TransactionDto], address: string, wasFetchMore: bool) =
method setTrxHistoryResult*[T](self: Module[T], transactions: seq[TransactionDto], address: string, wasFetchMore: bool) =
self.view.setTrxHistoryResult(transactions, address, wasFetchMore)
method setHistoryFetchState*(self: Module, addresses: seq[string], isFetching: bool) =
method setHistoryFetchState*[T](self: Module[T], addresses: seq[string], isFetching: bool) =
self.view.setHistoryFetchStateForAccounts(addresses, isFetching)
method setIsNonArchivalNode*[T](self: Module[T], isNonArchivalNode: bool) =

View File

@ -28,9 +28,6 @@ QtObject:
result.model = newModel()
result.modelVariant = newQVariant(result.model)
proc load*(self: View) =
self.delegate.viewDidLoad()
proc modelChanged*(self: View) {.signal.}
proc getModel(self: View): QVariant {.slot.} =

View File

@ -22,9 +22,6 @@ QtObject:
result.delegate = delegate
result.setup()
proc load*(self: View) =
self.delegate.viewDidLoad()
proc currentCurrencyChanged*(self: View) {.signal.}
proc updateCurrency*(self: View, currency: string) {.slot.} =