mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-22 04:21:44 +00:00
refactor(@desktop/wallet): Init transaction service
This commit is contained in:
parent
27d92f32f9
commit
8203643f86
@ -7,6 +7,7 @@ import ../../app_service/service/contacts/service as contact_service
|
||||
import ../../app_service/service/chat/service as chat_service
|
||||
import ../../app_service/service/community/service as community_service
|
||||
import ../../app_service/service/token/service as token_service
|
||||
import ../../app_service/service/transaction/service as transaction_service
|
||||
|
||||
import ../core/local_account_settings
|
||||
import ../modules/startup/module as startup_module
|
||||
@ -59,11 +60,11 @@ type
|
||||
chatService: chat_service.Service
|
||||
communityService: community_service.Service
|
||||
tokenService: token_service.Service
|
||||
transactionService: transaction_service.Service
|
||||
|
||||
# Core
|
||||
localAccountSettings: LocalAccountSettings
|
||||
localAccountSettingsVariant: QVariant
|
||||
# Modules
|
||||
startupModule: startup_module.AccessInterface
|
||||
mainModule: main_module.AccessInterface
|
||||
|
||||
@ -114,6 +115,7 @@ proc newAppController*(appService: AppService): AppController =
|
||||
result.chatService = chat_service.newService()
|
||||
result.communityService = community_service.newService(result.chatService)
|
||||
result.tokenService = token_service.newService()
|
||||
result.transactionService = transaction_service.newService()
|
||||
|
||||
# Core
|
||||
result.localAccountSettingsVariant = newQVariant(
|
||||
@ -122,9 +124,16 @@ proc newAppController*(appService: AppService): AppController =
|
||||
result.startupModule = startup_module.newModule[AppController](result,
|
||||
appService.status.events, appService.status.fleet, result.keychainService,
|
||||
result.accountsService)
|
||||
result.mainModule = main_module.newModule[AppController](result,
|
||||
appService.status.events, result.keychainService, result.accountsService,
|
||||
result.chatService, result.communityService)
|
||||
result.mainModule = main_module.newModule[AppController](
|
||||
result,
|
||||
appService.status.events,
|
||||
result.keychainService,
|
||||
result.accountsService,
|
||||
result.chatService,
|
||||
result.communityService,
|
||||
result.tokenService,
|
||||
result.transactionService
|
||||
)
|
||||
|
||||
#################################################
|
||||
# At the end of refactoring this will be moved to
|
||||
|
@ -11,6 +11,7 @@ import ../../../app_service/service/accounts/service_interface as accounts_servi
|
||||
import ../../../app_service/service/chat/service as chat_service
|
||||
import ../../../app_service/service/community/service as community_service
|
||||
import ../../../app_service/service/token/service as token_service
|
||||
import ../../../app_service/service/transaction/service as transaction_service
|
||||
|
||||
import eventemitter
|
||||
|
||||
@ -42,8 +43,9 @@ proc newModule*[T](
|
||||
keychainService: keychain_service.Service,
|
||||
accountsService: accounts_service.ServiceInterface,
|
||||
chatService: chat_service.Service,
|
||||
communityService: community_service.Service
|
||||
tokenService: token_service.Service
|
||||
communityService: community_service.Service,
|
||||
tokenService: token_service.Service,
|
||||
transactionService: transaction_service.Service
|
||||
): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
@ -63,7 +65,7 @@ proc newModule*[T](
|
||||
)
|
||||
|
||||
result.walletSectionModule = wallet_section_module.newModule[Module[T]](
|
||||
result, tokenService
|
||||
result, tokenService, transactionService
|
||||
)
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import ./transactions/module as transactions_module
|
||||
|
||||
|
||||
import ../../../../app_service/service/token/service as token_service
|
||||
import ../../../../app_service/service/transaction/service as transaction_service
|
||||
|
||||
import io_interface
|
||||
export io_interface
|
||||
@ -27,7 +28,11 @@ type
|
||||
mainAccountModule: main_account_module.AccessInterface
|
||||
transactionsModule: transactions_module.AccessInterface
|
||||
|
||||
proc newModule*[T](delegate: T, tokenService: token_service.Service): Module[T] =
|
||||
proc newModule*[T](
|
||||
delegate: T,
|
||||
tokenService: token_service.Service,
|
||||
transactionService: transaction_service.Service,
|
||||
): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
result.view = newView()
|
||||
@ -38,7 +43,7 @@ proc newModule*[T](delegate: T, tokenService: token_service.Service): Module[T]
|
||||
result.allTokensModule = all_tokens_module.newModule(result, tokenService)
|
||||
result.collectiblesModule = collectibles_module.newModule(result)
|
||||
result.mainAccountModule = main_account_module.newModule(result)
|
||||
result.transactionsModule = transactions_module.newModule(result)
|
||||
result.transactionsModule = transactions_module.newModule(result, transactionService)
|
||||
|
||||
method delete*[T](self: Module[T]) =
|
||||
self.accountTokensModule.delete
|
||||
|
@ -0,0 +1,23 @@
|
||||
import ./controller_interface
|
||||
import ../../../../../app_service/service/transaction/service as transaction_service
|
||||
|
||||
export controller_interface
|
||||
|
||||
type
|
||||
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
|
||||
delegate: T
|
||||
transactionService: transaction_service.ServiceInterface
|
||||
|
||||
proc newController*[T](
|
||||
delegate: T,
|
||||
transactionService: transaction_service.ServiceInterface
|
||||
): Controller[T] =
|
||||
result = Controller[T]()
|
||||
result.delegate = delegate
|
||||
result.transactionService = transactionService
|
||||
|
||||
method delete*[T](self: Controller[T]) =
|
||||
discard
|
||||
|
||||
method init*[T](self: Controller[T]) =
|
||||
discard
|
@ -0,0 +1,17 @@
|
||||
import ../../../../../app_service/service/token/service_interface as token_service
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for any input/interaction with this module.
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method init*(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
|
||||
|
@ -1,21 +1,25 @@
|
||||
import ./io_interface, ./view
|
||||
import ./io_interface, ./view, ./controller
|
||||
import ../../../../../app_service/service/transaction/service as transaction_service
|
||||
|
||||
export io_interface
|
||||
|
||||
type
|
||||
Module* [T: DelegateInterface] = ref object of AccessInterface
|
||||
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
||||
delegate: T
|
||||
view: View
|
||||
controller: controller.AccessInterface
|
||||
moduleLoaded: bool
|
||||
|
||||
proc newModule*[T](delegate: T): Module[T] =
|
||||
proc newModule*[T](delegate: T, transactionService: transaction_service.ServiceInterface): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
result.view = newView(result)
|
||||
result.controller = controller.newController[Module[T]](result, transactionService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
method delete*[T](self: Module[T]) =
|
||||
self.view.delete
|
||||
self.controller.delete
|
||||
|
||||
method load*[T](self: Module[T]) =
|
||||
self.moduleLoaded = true
|
||||
|
2
src/app_service/service/transaction/dto.nim
Normal file
2
src/app_service/service/transaction/dto.nim
Normal file
@ -0,0 +1,2 @@
|
||||
type
|
||||
Dto* = ref object of RootObj
|
30
src/app_service/service/transaction/service.nim
Normal file
30
src/app_service/service/transaction/service.nim
Normal file
@ -0,0 +1,30 @@
|
||||
import chronicles
|
||||
import status/statusgo_backend_new/transactions as transactions
|
||||
|
||||
import ./service_interface, ./dto
|
||||
|
||||
export service_interface
|
||||
|
||||
logScope:
|
||||
topics = "transaction-service"
|
||||
|
||||
type
|
||||
Service* = ref object of ServiceInterface
|
||||
|
||||
method delete*(self: Service) =
|
||||
discard
|
||||
|
||||
proc newService*(): Service =
|
||||
result = Service()
|
||||
|
||||
method init*(self: Service) =
|
||||
discard
|
||||
|
||||
method checkRecentHistory*(self: Service, addresses: seq[string]) =
|
||||
try:
|
||||
transactions.checkRecentHistory(addresses)
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "error: ", errDesription
|
||||
return
|
||||
|
16
src/app_service/service/transaction/service_interface.nim
Normal file
16
src/app_service/service/transaction/service_interface.nim
Normal file
@ -0,0 +1,16 @@
|
||||
import dto
|
||||
|
||||
export dto
|
||||
|
||||
type
|
||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for this service access.
|
||||
|
||||
method delete*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method init*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method checkRecentHistory*(self: ServiceInterface, addresses: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
Loading…
x
Reference in New Issue
Block a user