refactor(wallet2): the old way of fetching crypto services asynchronous is removed

This commit is contained in:
Sale Djenic 2021-11-16 14:05:25 +01:00
parent 141b664a0c
commit 5c0bb9b0b9
3 changed files with 0 additions and 63 deletions

View File

@ -1,16 +0,0 @@
include status/utils/json_utils
#################################################
# Async request for the list of services to buy/sell crypto
#################################################
const asyncGetCryptoServicesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[QObjectTaskArg](argEncoded)
var success: bool
let response = status_wallet.fetchCryptoServices(success)
var list: JsonNode
if(success):
list = response.parseJson()["result"]
arg.finish($list)

View File

@ -1,42 +0,0 @@
import NimQml
import json, chronicles
import ../../tasks/[qt, threadpool]
import status/[status, wallet2]
import status/statusgo_backend/wallet as status_wallet
include async_tasks
logScope:
topics = "wallet-async-service"
QtObject:
type WalletService* = ref object of QObject
status: Status
threadpool: ThreadPool
proc setup(self: WalletService) =
self.QObject.setup
proc delete*(self: WalletService) =
self.QObject.delete
proc newWalletService*(status: Status, threadpool: ThreadPool): WalletService =
new(result, delete)
result.status = status
result.threadpool = threadpool
result.setup()
proc onAsyncFetchCryptoServices*(self: WalletService, response: string) {.slot.} =
self.status.wallet2.onAsyncFetchCryptoServices(response)
proc asyncFetchCryptoServices*(self: WalletService) =
## Asynchronous request for the list of services to buy/sell crypto.
let arg = QObjectTaskArg(
tptr: cast[ByteAddress](asyncGetCryptoServicesTask),
vptr: cast[ByteAddress](self.vptr),
slot: "onAsyncFetchCryptoServices"
)
self.threadpool.start(arg)

View File

@ -7,12 +7,10 @@ import
./signals/signal_controller ./signals/signal_controller
import service/os_notification/service as os_notification_service import service/os_notification/service as os_notification_service
import async_service/wallet/service as wallet_async_service
export status_lib_status export status_lib_status
export marathon, task_runner, signal_controller export marathon, task_runner, signal_controller
export os_notification_service export os_notification_service
export wallet_async_service
logScope: logScope:
topics = "app-services" topics = "app-services"
@ -26,7 +24,6 @@ type AppService* = ref object
# services # services
osNotificationService*: OsNotificationService osNotificationService*: OsNotificationService
# async services # async services
walletService*: WalletService
proc newAppService*(status: Status, worker: MarathonWorker): AppService = proc newAppService*(status: Status, worker: MarathonWorker): AppService =
result = AppService() result = AppService()
@ -35,14 +32,12 @@ proc newAppService*(status: Status, worker: MarathonWorker): AppService =
result.marathon = newMarathon(worker) result.marathon = newMarathon(worker)
result.signalController = newSignalsController(status) result.signalController = newSignalsController(status)
result.osNotificationService = newOsNotificationService(status) result.osNotificationService = newOsNotificationService(status)
result.walletService = newWalletService(status, result.threadpool)
proc delete*(self: AppService) = proc delete*(self: AppService) =
self.threadpool.teardown() self.threadpool.teardown()
self.marathon.teardown() self.marathon.teardown()
self.signalController.delete() self.signalController.delete()
self.osNotificationService.delete() self.osNotificationService.delete()
self.walletService.delete()
proc onLoggedIn*(self: AppService) = proc onLoggedIn*(self: AppService) =
self.marathon.onLoggedIn() self.marathon.onLoggedIn()