refactor(@desktop/wallet): enable check recent history

This commit is contained in:
Anthony Laibe 2021-10-20 10:02:17 +02:00 committed by Iuri Matias
parent b7eaef8a84
commit 142d2a9188
7 changed files with 25 additions and 14 deletions

View File

@ -122,11 +122,12 @@ proc newAppController*(appService: AppService): AppController =
result.chatService = chat_service.newService()
result.communityService = community_service.newService(result.chatService)
result.tokenService = token_service.newService(result.settingService)
result.transactionService = transaction_service.newService()
result.collectibleService = collectible_service.newService()
result.walletAccountService = wallet_account_service.newService(
result.settingService, result.tokenService
)
result.transactionService = transaction_service.newService(result.walletAccountService)
# Core
result.localAccountSettingsVariant = newQVariant(
@ -218,6 +219,7 @@ proc load*(self: AppController) =
self.communityService.init()
self.tokenService.init()
self.walletAccountService.init()
self.transactionService.init()
self.mainModule.load()

View File

@ -10,7 +10,7 @@ type
proc newController*[T](
delegate: T,
transactionService: transaction_service.ServiceInterface
transactionService: transaction_service.ServiceInterface,
): Controller[T] =
result = Controller[T]()
result.delegate = delegate
@ -20,4 +20,7 @@ method delete*[T](self: Controller[T]) =
discard
method init*[T](self: Controller[T]) =
discard
discard
method checkRecentHistory*[T](self: Controller[T]) =
self.transactionService.checkRecentHistory()

View File

@ -1,5 +1,3 @@
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.
@ -10,6 +8,9 @@ method delete*(self: AccessInterface) {.base.} =
method init*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method checkRecentHistory*(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

@ -28,6 +28,8 @@ method delete*[T](self: Module[T]) =
self.controller.delete
method load*[T](self: Module[T]) =
self.controller.checkRecentHistory()
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =

View File

@ -1,6 +1,7 @@
import chronicles
import chronicles, sequtils, sugar
import status/statusgo_backend_new/transactions as transactions
import ../wallet_account/service as wallet_account_service
import ./service_interface, ./dto
export service_interface
@ -9,22 +10,24 @@ logScope:
topics = "transaction-service"
type
Service* = ref object of ServiceInterface
Service* = ref object of service_interface.ServiceInterface
walletAccountService: wallet_account_service.ServiceInterface
method delete*(self: Service) =
discard
proc newService*(): Service =
proc newService*(walletAccountService: wallet_account_service.ServiceInterface): Service =
result = Service()
result.walletAccountService = walletAccountService
method init*(self: Service) =
discard
method checkRecentHistory*(self: Service, addresses: seq[string]) =
method checkRecentHistory*(self: Service) =
try:
let addresses = self.walletAccountService.getWalletAccounts().map(a => a.address)
transactions.checkRecentHistory(addresses)
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
return

View File

@ -12,5 +12,5 @@ method delete*(self: ServiceInterface) {.base.} =
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")
method checkRecentHistory*(self: ServiceInterface) {.base.} =
raise newException(ValueError, "No implementation available")

2
vendor/status-lib vendored

@ -1 +1 @@
Subproject commit 5de6e894a57eaa2665d0d3c2207f9bd836ac82ff
Subproject commit ce0314eddaf9ce414b99abafc0b3e564ec1e1c88