refactor(@desktop/general): dependencies to the `status-lib` removed

Fixes #4395
This commit is contained in:
Sale Djenic 2022-01-10 12:03:28 +01:00
parent 9fc9f698d9
commit 4d042f80aa
96 changed files with 466 additions and 271 deletions

View File

@ -1,5 +1,6 @@
import NimQml
import ../../app_service/service/general/service as general_service
import ../../app_service/service/os_notification/service as os_notification_service
import ../../app_service/service/eth/service as eth_service
import ../../app_service/service/keychain/service as keychain_service
@ -49,6 +50,7 @@ type
globalUtilsVariant: QVariant
# Services
generalService: general_service.Service
osNotificationService: os_notification_service.Service
keychainService: keychain_service.Service
ethService: eth_service.Service
@ -98,9 +100,9 @@ proc mainDidLoad*(self: AppController)
#################################################
proc connect(self: AppController) =
self.statusFoundation.status.events.once("nodeStopped") do(a: Args):
# TODO: remove this once accounts are not tracked in the AccountsModel
self.statusFoundation.status.reset()
self.statusFoundation.events.once("nodeStopped") do(a: Args):
# not sure, but maybe we should take some actions when node stops
discard
proc newAppController*(statusFoundation: StatusFoundation): AppController =
result = AppController()
@ -114,31 +116,32 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.globalUtilsVariant = newQVariant(singletonInstance.utils)
# Services
result.generalService = general_service.newService()
result.settingsService = settings_service.newService()
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
result.settingsService)
result.osNotificationService = os_notification_service.newService(statusFoundation.status.events)
result.keychainService = keychain_service.newService(statusFoundation.status.events)
result.osNotificationService = os_notification_service.newService(statusFoundation.events)
result.keychainService = keychain_service.newService(statusFoundation.events)
result.ethService = eth_service.newService()
result.accountsService = accounts_service.newService(statusFoundation.fleetConfiguration)
result.networkService = network_service.newService()
result.contactsService = contacts_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.chatService = chat_service.newService(statusFoundation.status.events, result.contactsService)
result.communityService = community_service.newService(statusFoundation.status.events, result.chatService)
result.messageService = message_service.newService(statusFoundation.status.events, statusFoundation.threadpool)
result.activityCenterService = activity_center_service.newService(statusFoundation.status.events,
result.contactsService = contacts_service.newService(statusFoundation.events, statusFoundation.threadpool)
result.chatService = chat_service.newService(statusFoundation.events, result.contactsService)
result.communityService = community_service.newService(statusFoundation.events, result.chatService)
result.messageService = message_service.newService(statusFoundation.events, statusFoundation.threadpool)
result.activityCenterService = activity_center_service.newService(statusFoundation.events,
statusFoundation.threadpool, result.chatService)
result.tokenService = token_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.tokenService = token_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService)
result.collectibleService = collectible_service.newService(result.settingsService)
result.walletAccountService = wallet_account_service.newService(statusFoundation.status.events, result.settingsService,
result.walletAccountService = wallet_account_service.newService(statusFoundation.events, result.settingsService,
result.accountsService, result.tokenService)
result.transactionService = transaction_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.walletAccountService)
result.bookmarkService = bookmark_service.newService()
result.profileService = profile_service.newService()
result.stickersService = stickers_service.newService(
statusFoundation.status.events,
statusFoundation.events,
statusFoundation.threadpool,
result.ethService,
result.settingsService,
@ -147,31 +150,31 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.networkService,
result.chatService
)
result.aboutService = about_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.aboutService = about_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService)
result.dappPermissionsService = dapp_permissions_service.newService()
result.languageService = language_service.newService()
# result.mnemonicService = mnemonic_service.newService()
result.privacyService = privacy_service.newService(statusFoundation.status.events, result.settingsService,
result.privacyService = privacy_service.newService(statusFoundation.events, result.settingsService,
result.accountsService)
result.providerService = provider_service.newService(result.dappPermissionsService, result.settingsService)
result.savedAddressService = saved_address_service.newService(statusFoundation.status.events)
result.devicesService = devices_service.newService(statusFoundation.status.events, result.settingsService)
result.mailserversService = mailservers_service.newService(statusFoundation.status.events, statusFoundation.marathon,
result.savedAddressService = saved_address_service.newService(statusFoundation.events)
result.devicesService = devices_service.newService(statusFoundation.events, result.settingsService)
result.mailserversService = mailservers_service.newService(statusFoundation.events, statusFoundation.marathon,
result.settingsService, result.nodeConfigurationService, statusFoundation.fleetConfiguration)
result.nodeService = node_service.newService(statusFoundation.status.events, statusFoundation.threadpool,
result.nodeService = node_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.settingsService)
# Modules
result.startupModule = startup_module.newModule[AppController](
result,
statusFoundation.status.events,
statusFoundation.events,
result.keychainService,
result.accountsService
)
result.mainModule = main_module.newModule[AppController](
result,
statusFoundation.status.events,
statusFoundation.events,
result.keychainService,
result.accountsService,
result.chatService,
@ -241,6 +244,7 @@ proc delete*(self: AppController) =
self.messageService.delete
self.privacyService.delete
self.profileService.delete
self.generalService.delete
proc startupDidLoad*(self: AppController) =
singletonInstance.engine.setRootContextProperty("localAppSettings", self.localAppSettingsVariant)
@ -257,6 +261,7 @@ proc mainDidLoad*(self: AppController) =
self.mainModule.checkForStoringPassword()
proc start*(self: AppController) =
self.generalService.init()
self.ethService.init()
self.accountsService.init()
@ -294,7 +299,7 @@ proc load(self: AppController) =
# load main module
self.mainModule.load(
self.statusFoundation.status.events,
self.statusFoundation.events,
self.settingsService,
self.contactsService,
self.chatService,
@ -303,7 +308,7 @@ proc load(self: AppController) =
)
proc userLoggedIn*(self: AppController) =
self.statusFoundation.status.startMessenger()
self.generalService.startMessenger()
self.load()
# Once user is logged in and main module is loaded we need to check if it gets here importing mnemonic or not

View File

@ -0,0 +1,60 @@
import # system libs
tables
import # deps
uuids
type
Args* = ref object of RootObj # ...args
Handler* = proc (args: Args) {.closure.} # callback function type
EventEmitter* = ref object
events: Table[string, Table[UUID, Handler]]
proc createEventEmitter*(): EventEmitter =
result.new
result.events = initTable[string, Table[UUID, Handler]]()
proc on(this: EventEmitter, name: string, handlerId: UUID, handler: Handler): void =
if this.events.hasKey(name):
this.events[name].add handlerId, handler
return
this.events[name] = [(handlerId, handler)].toTable
proc on*(this: EventEmitter, name: string, handler: Handler): void =
var uuid: UUID
this.on(name, uuid, handler)
proc once*(this:EventEmitter, name:string, handler:Handler): void =
var handlerId = genUUID()
this.on(name, handlerId) do(a: Args):
handler(a)
this.events[name].del handlerId
proc emit*(this:EventEmitter, name:string, args:Args): void =
if this.events.hasKey(name):
# collect the handlers before executing them
# because of 'once' proc, we also mutate
# this.events. This can cause unexpected behaviour
# while having an iterator on this.events
var handlers: seq[Handler] = @[]
for (id, handler) in this.events[name].pairs:
handlers.add(handler)
for i in 0..len(handlers)-1:
handlers[i](args)
when isMainModule:
block:
type ReadyArgs = ref object of Args
text: string
var evts = createEventEmitter()
evts.on("ready") do(a: Args):
var args = ReadyArgs(a)
echo args.text, ": from [1st] handler"
evts.once("ready") do(a: Args):
var args = ReadyArgs(a)
echo args.text, ": from [2nd] handler"
evts.emit("ready", ReadyArgs(text:"Hello, World"))
evts.emit("ready", ReadyArgs(text:"Hello, World"))

View File

@ -1,7 +1,6 @@
import NimQml, chronicles, task_runner
import ../../constants
import status/status as status_lib_status
import
eventemitter,
./fleets/fleet_configuration,
./tasks/marathon,
./tasks/marathon/mailserver/controller,
@ -9,11 +8,11 @@ import
./tasks/threadpool,
./signals/signals_manager
export status_lib_status
export eventemitter
export marathon, task_runner, signals_manager, fleet_configuration
type StatusFoundation* = ref object
status*: Status # in one point of time this should be completely removed
events*: EventEmitter
fleetConfiguration*: FleetConfiguration
threadpool*: ThreadPool
marathon*: Marathon
@ -23,16 +22,13 @@ type StatusFoundation* = ref object
proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
result = StatusFoundation()
result.status = newStatusInstance()
result.status.initNode(STATUSGODIR, KEYSTOREDIR)
result.events = createEventEmitter()
result.fleetConfiguration = newFleetConfiguration(fleetConfig)
result.mailserverController = newMailserverController(result.status.events)
result.mailserverController = newMailserverController(result.events)
result.mailserverWorker = newMailserverWorker(cast[ByteAddress](result.mailserverController.vptr))
result.threadpool = newThreadPool()
result.marathon = newMarathon(result.mailserverWorker)
result.signalsManager = newSignalsManager(result.status.events)
result.signalsManager = newSignalsManager(result.events)
proc delete*(self: StatusFoundation) =
self.threadpool.teardown()
@ -41,7 +37,6 @@ proc delete*(self: StatusFoundation) =
self.mailserverController.delete()
self.fleetConfiguration.delete()
self.signalsManager.delete()
self.status.reset()
proc onLoggedIn*(self: StatusFoundation) =
self.marathon.onLoggedIn()

View File

@ -1,8 +1,7 @@
import json
import json_serialization
import signal_type
import eventemitter
import ../../eventemitter
export signal_type

View File

@ -2,11 +2,7 @@ import json
import base
# Step by step we should remove all these types from `status-lib`
import status/types/[activity_center_notification, removed_message]
import status/types/community as old_community
import ../../../../app_service/service/message/dto/[message, pinned_message_update, reaction]
import ../../../../app_service/service/message/dto/[message, pinned_message_update, reaction, removed_message]
import ../../../../app_service/service/chat/dto/[chat]
import ../../../../app_service/service/community/dto/[community]
import ../../../../app_service/service/activity_center/dto/[notification]
@ -21,10 +17,10 @@ type MessageSignal* = ref object of Signal
devices*: seq[DeviceDto]
emojiReactions*: seq[ReactionDto]
communities*: seq[CommunityDto]
membershipRequests*: seq[old_community.CommunityMembershipRequest]
membershipRequests*: seq[CommunityMembershipRequestDto]
activityCenterNotifications*: seq[ActivityCenterNotificationDto]
statusUpdates*: seq[StatusUpdateDto]
deletedMessages*: seq[RemovedMessage]
deletedMessages*: seq[RemovedMessageDto]
proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
var signal:MessageSignal = MessageSignal()
@ -64,11 +60,11 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
if event["event"]{"requestsToJoinCommunity"} != nil:
for jsonCommunity in event["event"]["requestsToJoinCommunity"]:
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequest)
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequestDto())
if event["event"]{"removedMessages"} != nil:
for jsonRemovedMessage in event["event"]["removedMessages"]:
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessage)
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessageDto())
if event["event"]{"activityCenterNotifications"} != nil:
for jsonNotification in event["event"]["activityCenterNotifications"]:

View File

@ -1,5 +1,5 @@
import NimQml, json, strutils, chronicles, json_serialization
import eventemitter
import ../eventemitter
include types

View File

@ -1,5 +1,6 @@
import NimQml, times, strutils, json, json_serialization, chronicles
import ../../../eventemitter
import ../../../fleets/fleet_configuration
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/node_configuration/service_interface as node_config_service
@ -12,8 +13,6 @@ import status/statusgo_backend_new/general as status_general
import events
import ../../common as task_runner_common
import eventemitter
logScope:
topics = "mailserver controller"

View File

@ -1,8 +1,6 @@
import # vendor libs
NimQml, json_serialization
import NimQml, json_serialization
import # status-desktop libs
eventemitter
import ../../../eventemitter
type
MailserverEvents* = ref object

View File

@ -1,6 +1,3 @@
import # std libs
json
import # vendor libs
chronicles, chronos, json_serialization, task_runner

View File

@ -1,6 +1,6 @@
from ../modules/shared_models/section_item import SectionType
import eventemitter
import ../core/eventemitter
export SectionType

View File

@ -1,9 +1,9 @@
import Tables, stint
import eventemitter
import ./controller_interface
import ./io_interface
import ../../../../app/core/signals/types
import ../../../core/eventemitter
import ../../../core/signals/types
import ../../../../app_service/service/activity_center/service as activity_center_service
import ../../../../app_service/service/contacts/service as contacts_service
import ../../../../app_service/service/chat/service as chat_service

View File

@ -1,11 +1,11 @@
import NimQml, Tables, stint, sugar, sequtils
import eventemitter
import ./io_interface, ./view, ./controller
import ./item as notification_item
import ../../shared_models/message_item as message_item
import ../../shared_models/message_item_qobject as message_item_qobject
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/activity_center/service as activity_center_service
import ../../../../app_service/service/contacts/service as contacts_service

View File

@ -8,7 +8,7 @@ import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/message/service as message_service
import ../../../core/signals/types
import eventemitter
import ../../../core/eventemitter
export controller_interface

View File

@ -10,13 +10,12 @@ import ../../shared_models/message_item
import ../../../global/global_singleton
import ../../../global/app_sections_config as conf
import ../../../core/eventemitter
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/message/service as message_service
import eventemitter
export io_interface
logScope:

View File

@ -10,7 +10,7 @@ import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/message/service as message_service
import ../../../../core/signals/types
import eventemitter
import ../../../../core/eventemitter
export controller_interface

View File

@ -7,7 +7,7 @@ import ../../../../../../app_service/service/community/service as community_serv
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/message/service as message_service
import eventemitter
import ../../../../../core/eventemitter
export controller_interface

View File

@ -6,14 +6,12 @@ import ../../../../shared_models/message_model
import ../../../../shared_models/message_item
import ../../../../shared_models/message_reaction_item
import ../../../../../global/global_singleton
import ../../../../../core/eventemitter
import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/message/service as message_service
import eventemitter
export io_interface
logScope:

View File

@ -6,6 +6,7 @@ import ../../../shared_models/message_model as pinned_msg_model
import ../../../shared_models/message_item as pinned_msg_item
import ../../../shared_models/message_reaction_item as pinned_msg_reaction_item
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import input_area/module as input_area_module
import messages/module as messages_module
@ -17,8 +18,6 @@ import ../../../../../app_service/service/chat/service as chat_service
import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/message/service as message_service
import eventemitter
export io_interface
logScope:

View File

@ -6,7 +6,7 @@ import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service
import eventemitter
import ../../../../../core/eventemitter
export controller_interface

View File

@ -3,13 +3,11 @@ import io_interface
import ../io_interface as delegate_interface
import view, item, model, controller
import ../../../../../global/global_singleton
import ../../../../../core/eventemitter
import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/message/service as message_service
import eventemitter
export io_interface
type

View File

@ -9,7 +9,7 @@ import ../../../../app_service/service/chat/service as chat_service
import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/message/service as message_service
import eventemitter
import ../../../core/eventemitter
export controller_interface

View File

@ -8,14 +8,13 @@ import ../../shared_models/contacts_model as contacts_model
import chat_content/module as chat_content_module
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/settings/service_interface as settings_service
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/message/service as message_service
import eventemitter
export io_interface
logScope:

View File

@ -6,7 +6,7 @@ import ../../../../../app_service/service/chat/service as chat_service
import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/message/service as message_service
import eventemitter
import ../../../../core/eventemitter
method delete*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -1,9 +1,9 @@
import Tables, stint
import eventemitter
import ./controller_interface
import ./io_interface
import ../../../../app/core/signals/types
import ../../../core/signals/types
import ../../../core/eventemitter
import ../../../../app_service/service/community/service as community_service
export controller_interface

View File

@ -1,12 +1,12 @@
import NimQml, json, sequtils, sugar
import eventemitter
import ./io_interface
import ../io_interface as delegate_interface
import ./view, ./controller
import ../../shared_models/section_item
import ../../shared_models/member_item
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/community/service as community_service
export io_interface

View File

@ -1,6 +1,8 @@
import ../shared_models/section_item, controller_interface, io_interface, chronicles
import ../../global/global_singleton
import ../../global/app_signals
import ../../core/signals/types
import ../../core/eventemitter
import ../../../app_service/service/settings/service_interface as settings_service
import ../../../app_service/service/keychain/service as keychain_service
import ../../../app_service/service/accounts/service_interface as accounts_service
@ -9,9 +11,6 @@ import ../../../app_service/service/community/service as community_service
import ../../../app_service/service/contacts/service as contacts_service
import ../../../app_service/service/message/service as message_service
import ../../core/signals/types
import eventemitter
export controller_interface
logScope:

View File

@ -42,7 +42,7 @@ import ../../../app_service/service/node_configuration/service_interface as node
import ../../../app_service/service/devices/service as devices_service
import ../../../app_service/service/mailservers/service as mailservers_service
import eventemitter
import ../../core/eventemitter
export io_interface

View File

@ -6,8 +6,8 @@ import ../../../../app_service/service/settings/service_interface as settings_se
import ../../../../app_service/service/node/service as node_service
import ../../../../app_service/service/node_configuration/service as node_configuration_service
import eventemitter
import ../../../core/signals/types
import ../../../core/eventemitter
import ../../../core/fleets/fleet_configuration
export controller_interface

View File

@ -5,15 +5,12 @@ import ../io_interface as delegate_interface
import view, controller
import ../../../global/global_singleton
import ../../../core/signals/types
import ../../../core/eventemitter
import ../../../../app_service/service/settings/service_interface as settings_service
import ../../../../app_service/service/node/service as node_service
import ../../../../app_service/service/node_configuration/service as node_configuration_service
import ../../../core/signals/types
import eventemitter
export io_interface
type

View File

@ -4,7 +4,7 @@ import ../../../../app_service/service/chat/service as chat_service
import ../../../../app_service/service/community/service as community_service
import ../../../../app_service/service/message/service as message_service
import eventemitter
import ../../../core/eventemitter
method delete*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -1,7 +1,7 @@
import ./controller_interface
import eventemitter
import io_interface
import ../../../../../app_service/service/about/service as about_service
import ../../../../core/eventemitter
export controller_interface

View File

@ -1,10 +1,9 @@
import NimQml
import eventemitter
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/about/service as about_service
export io_interface

View File

@ -2,13 +2,12 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../../../core/fleets/fleet_configuration
import ../../../../global/app_signals
import ../../../../core/eventemitter
import ../../../../core/fleets/fleet_configuration
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/node_configuration/service_interface as node_configuration_service
import eventemitter
export controller_interface
logScope:

View File

@ -4,12 +4,11 @@ import ../io_interface as delegate_interface
import view, controller, custom_networks_model
import ../../../../../constants
import ../../../../core/eventemitter
import ../../../../global/global_singleton
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/node_configuration/service_interface as node_configuration_service
import eventemitter
export io_interface
logScope:

View File

@ -1,10 +1,9 @@
import ./controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/contacts/service as contacts_service
import eventemitter
export controller_interface
type

View File

@ -5,10 +5,9 @@ import ../../../shared_models/contacts_item
import ../../../shared_models/contacts_model
import ../io_interface as delegate_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/contacts/service as contacts_service
import eventemitter
export io_interface
logScope:

View File

@ -2,11 +2,10 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/devices/service as devices_service
import eventemitter
export controller_interface
logScope:

View File

@ -3,11 +3,10 @@ import io_interface
import ../io_interface as delegate_interface
import view, controller, model, item
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/devices/service as devices_service
import eventemitter
export io_interface
logScope:

View File

@ -1,7 +1,7 @@
import NimQml
import io_interface, view, controller
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/profile/service as profile_service
import ../../../../app_service/service/accounts/service as accounts_service
import ../../../../app_service/service/settings/service_interface as settings_service
@ -24,8 +24,6 @@ import ./devices/module as devices_module
import ./sync/module as sync_module
import ./notifications/module as notifications_module
import eventemitter
export io_interface
type

View File

@ -2,10 +2,9 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/chat/service as chat_service
import eventemitter
export controller_interface
logScope:

View File

@ -3,10 +3,9 @@ import io_interface
import ../io_interface as delegate_interface
import view, controller, model, item
import ../../../../core/eventemitter
import ../../../../../app_service/service/chat/service as chat_service
import eventemitter
export io_interface
logScope:

View File

@ -1,11 +1,10 @@
import ./controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/privacy/service as privacy_service
import eventemitter
export controller_interface
type

View File

@ -3,11 +3,10 @@ import NimQml, chronicles
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/privacy/service as privacy_service
import eventemitter
export io_interface
type

View File

@ -2,12 +2,11 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../core/fleets/fleet_configuration
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/mailservers/service as mailservers_service
import eventemitter
export controller_interface
logScope:

View File

@ -3,11 +3,10 @@ import io_interface
import ../io_interface as delegate_interface
import view, controller, model, item
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service_interface as settings_service
import ../../../../../app_service/service/mailservers/service as mailservers_service
import eventemitter
export io_interface
logScope:

View File

@ -1,7 +1,9 @@
import Tables, stint
import eventemitter
import ./controller_interface
import ./io_interface
import ../../../core/eventemitter
import ../../../../app_service/service/stickers/service as stickers_service
import ../../../../app_service/service/eth/utils as eth_utils

View File

@ -1,8 +1,8 @@
import NimQml, Tables, stint, sugar, sequtils
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/stickers/service as stickers_service
export io_interface

View File

@ -1,8 +1,9 @@
import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
export io_interface

View File

@ -1,9 +1,9 @@
import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./item, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
import ../account_tokens/model as account_tokens
import ../account_tokens/item as account_tokens_item

View File

@ -1,6 +1,7 @@
import ./controller_interface
import ./io_interface
import eventemitter
import ../../../../core/eventemitter
import ../../../../../app_service/service/token/service as token_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service

View File

@ -1,10 +1,10 @@
import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller, ./item
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/token/service as token_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service

View File

@ -1,7 +1,6 @@
import eventemitter
import ./io_interface, ./controller
import ../io_interface as delegate_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/collectible/service as collectible_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service

View File

@ -1,6 +1,7 @@
import NimQml
import eventemitter
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
import ./io_interface, ./view, ./controller

View File

@ -1,9 +1,7 @@
import NimQml
import eventemitter
import ./controller, ./view
import ./io_interface as io_interface
import ../../../global/global_singleton
import ./account_tokens/module as account_tokens_module
import ./accounts/module as accountsModule
@ -13,7 +11,8 @@ import ./current_account/module as current_account_module
import ./transactions/module as transactions_module
import ./saved_addresses/module as saved_addresses_module
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/token/service as token_service
import ../../../../app_service/service/transaction/service as transaction_service
import ../../../../app_service/service/collectible/service as collectible_service

View File

@ -1,6 +1,6 @@
import eventemitter
import ./controller_interface
import io_interface
import ../../../../core/eventemitter
import ../../../../../app_service/service/saved_address/service as saved_address_service
export controller_interface

View File

@ -1,7 +1,8 @@
import NimQml, sugar, sequtils
import eventemitter
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/saved_address/service as saved_address_service
import ./io_interface, ./view, ./controller, ./item

View File

@ -1,16 +1,11 @@
import NimQml, json, json_serialization, stint, tables, eventemitter, sugar, sequtils
import NimQml, json, json_serialization, stint, tables, sugar, sequtils
import ./controller_interface
import io_interface
import ../../../../../app_service/service/transaction/service as transaction_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
import
status/[status, wallet]
export controller_interface
import status/types/transaction
import ../../../../core/[main]
import ../../../../core/tasks/[qt, threadpool]

View File

@ -1,7 +1,7 @@
import NimQml, Tables, strutils, strformat, sequtils, tables, sugar, algorithm
import status/utils
import ./item
import ../../../../../app_service/service/eth/utils as eth_service_utils
import ../../../../../app_service/service/transaction/dto
type
@ -174,7 +174,7 @@ QtObject:
var allTxs = self.items.concat(newTxItems)
allTxs.sort(cmpTransactions, SortOrder.Descending)
allTxs.deduplicate(tx => tx.getId())
eth_service_utils.deduplicate(allTxs, tx => tx.getId())
self.setItems(allTxs)
self.setHasMore(true)

View File

@ -1,8 +1,9 @@
import NimQml, eventemitter, stint
import NimQml, stint
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/transaction/service as transaction_service
import ../../../../../app_service/service/wallet_account/service as wallet_account_service

View File

@ -3,12 +3,11 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../core/signals/types
import ../../core/eventemitter
import ../../../app_service/service/keychain/service as keychain_service
import ../../../app_service/service/accounts/service_interface as accounts_service
import ../../core/signals/types
import eventemitter
export controller_interface
logScope:

View File

@ -3,13 +3,11 @@ import NimQml, Tables
import controller_interface
import io_interface
import ../../../global/global_singleton
import ../../../core/signals/types
import ../../../core/eventemitter
import ../../../../app_service/service/keychain/service as keychain_service
import ../../../../app_service/service/accounts/service_interface as accounts_service
import ../../../core/signals/types
import eventemitter
export controller_interface
type

View File

@ -3,12 +3,10 @@ import io_interface
import ../io_interface as delegate_interface
import view, controller, item
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/keychain/service as keychain_service
import ../../../../app_service/service/accounts/service_interface as accounts_service
import eventemitter
export io_interface
type

View File

@ -3,15 +3,13 @@ import NimQml
import io_interface
import view, controller
import ../../global/global_singleton
import ../../core/eventemitter
import onboarding/module as onboarding_module
import login/module as login_module
import ../../../app_service/service/keychain/service as keychain_service
import ../../../app_service/service/accounts/service_interface as accounts_service
import eventemitter
export io_interface
type

View File

@ -3,10 +3,9 @@ import Tables, chronicles
import controller_interface
import io_interface
import ../../../../app_service/service/accounts/service_interface as accounts_service
import ../../../core/signals/types
import eventemitter
import ../../../core/eventemitter
import ../../../../app_service/service/accounts/service_interface as accounts_service
export controller_interface

View File

@ -3,11 +3,9 @@ import io_interface
import ../io_interface as delegate_interface
import view, controller, item
import ../../../global/global_singleton
import ../../../core/eventemitter
import ../../../../app_service/service/accounts/service_interface as accounts_service
import eventemitter
export io_interface
type

View File

@ -1,6 +1,6 @@
import NimQml, json, chronicles
import eventemitter
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ../settings/service as settings_service

View File

@ -1,12 +1,11 @@
from stew/base32 import nil
from stew/base58 import nil
import chronicles, httpclient, net
import chronicles, httpclient, net, options
import strutils
import semver
import ../provider/service as provider_service
import ../ens/utils as ens_utils
import status/statusgo_backend_new/ens as status_ens
const APP_UPDATES_ENS* = "desktop.status.eth"
const CHECK_VERSION_TIMEOUT_MS* = 5000
@ -17,13 +16,13 @@ type
url*: string
proc getLatestVersion*(): VersionInfo =
let contentHash = contenthash(APP_UPDATES_ENS)
if contentHash == "":
let contentHash = ens_utils.getContentHash(APP_UPDATES_ENS)
if contentHash.isNone():
raise newException(ValueError, "ENS does not have a content hash")
var url: string = ""
let decodedHash = contentHash.decodeENSContentHash()
let decodedHash = ens_utils.decodeENSContentHash(contentHash.get())
case decodedHash[0]:
of ENSType.IPFS:
@ -41,7 +40,7 @@ proc getLatestVersion*(): VersionInfo =
else:
warn "Unknown content for", contentHash
raise newException(ValueError, "Unknown content for " & contentHash)
raise newException(ValueError, "Unknown content for " & contentHash.get())
# Read version from folder
let secureSSLContext = newContext()

View File

@ -1,6 +1,6 @@
import NimQml, json, sequtils, chronicles, strutils, strutils, stint
import eventemitter
import ../../../app/core/eventemitter
import ../../../app/core/[main]
import ../../../app/core/tasks/[qt, threadpool]

View File

@ -7,16 +7,11 @@ import ../contacts/service as contact_service
import status/statusgo_backend_new/chat as status_chat
import status/statusgo_backend_new/chatCommands as status_chat_commands
import ../../../app/global/global_singleton
import ../../../app/core/eventemitter
import ../../../constants
from ../../common/account_constants import ZERO_ADDRESS
# TODO: We need to remove these `status-lib` types from here
import status/types/[message]
import status/types/chat as chat_type
import eventemitter
export chat_dto

View File

@ -1,13 +1,15 @@
import NimQml, Tables, json, sequtils, std/algorithm, strformat, chronicles, json_serialization
import eventemitter
import ./dto/community as community_dto
export community_dto
import ../../../app/global/global_singleton
import ../chat/service as chat_service
import ../../../app/global/global_singleton
import ../../../app/core/eventemitter
import status/statusgo_backend_new/communities as status_go
export community_dto
logScope:
topics = "community-service"

View File

@ -1,5 +1,5 @@
import os
import status/ens as status_ens
import ../ens/utils as ens_utils
include ../../common/json_utils
include ../../../app/core/tasks/common
@ -19,8 +19,8 @@ const lookupContactTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
var address = ""
if not pubkey.startsWith("0x"):
# TODO refactor those calls to use the new backend and also do it in a signle call
pubkey = status_ens.pubkey(arg.value)
address = status_ens.address(arg.value)
pubkey = ens_utils.pubkey(arg.value)
address = ens_utils.address(arg.value)
let output = %*{
"id": pubkey,

View File

@ -2,6 +2,7 @@ import NimQml, Tables, json, sequtils, strformat, chronicles, strutils, times, s
import ../../../app/global/global_singleton
import ../../../app/core/signals/types
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ./dto/contacts as contacts_dto
@ -12,8 +13,6 @@ import status/statusgo_backend_new/accounts as status_accounts
import status/statusgo_backend_new/chat as status_chat
import status/statusgo_backend_new/utils as status_utils
import eventemitter
export contacts_dto, status_update_dto, contact_details
include async_tasks

View File

@ -1,11 +1,11 @@
import NimQml, json, sequtils, system, chronicles
import ../../../app/core/signals/types
import ./dto/device as device_dto
import ../settings/service as settings_service
import status/statusgo_backend_new/installations as status_installations
import eventemitter
import ../../../app/core/signals/types
import ../../../app/core/eventemitter
import status/statusgo_backend_new/installations as status_installations
export device_dto

View File

@ -1,14 +1,15 @@
import Tables, json, chronicles, strutils
import sets
import options
import algorithm, strformat, sets, options
import chronicles, libp2p/[multihash, multicodec, cid]
import nimcrypto
import nimcrypto, stint
include ../../common/json_utils
import status/statusgo_backend_new/ens as status_go
import status/statusgo_backend_new/eth as status_eth
logScope:
topics = "ens-utils"
const domain* = ".stateofus.eth"
type
ENSType* {.pure.} = enum
IPFS,
@ -16,10 +17,61 @@ type
IPNS,
UNKNOWN
proc addDomain(username: string): string =
if username.endsWith(".eth"):
return username
else:
return username & domain
proc namehash(ensName:string): string =
let name = ensName.toLower()
var node:array[32, byte]
node.fill(0)
var parts = name.split(".")
for i in countdown(parts.len - 1,0):
let elem = keccak_256.digest(parts[i]).data
var concatArrays: array[64, byte]
concatArrays[0..31] = node
concatArrays[32..63] = elem
node = keccak_256.digest(concatArrays).data
result = "0x" & node.toHex()
const registry* = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
const resolver_signature = "0x0178b8bf"
proc resolver(usernameHash: string): string =
let payload = %* [{
"to": registry,
"from": "0x0000000000000000000000000000000000000000",
"data": fmt"{resolver_signature}{userNameHash}"
}, "latest"]
var resolverAddr = status_eth.doEthCall(payload).result.getStr()
resolverAddr.removePrefix("0x000000000000000000000000")
result = "0x" & resolverAddr
const contenthash_signature = "0xbc1c58d1" # contenthash(bytes32)
proc contenthash(ensAddr: string): string =
var ensHash = namehash(ensAddr)
ensHash.removePrefix("0x")
let ensResolver = resolver(ensHash)
let payload = %* [{
"to": ensResolver,
"from": "0x0000000000000000000000000000000000000000",
"data": fmt"{contenthash_signature}{ensHash}"
}, "latest"]
let bytesResponse = status_eth.doEthCall(payload).result.getStr()
if bytesResponse == "0x":
return ""
let size = fromHex(Stuint[256], bytesResponse[66..129]).truncate(int)
result = bytesResponse[130..129+size*2]
proc getContentHash*(ens: string): Option[string] =
try:
let contentHash = status_go.contenthash(ens)
let contentHash = contenthash(ens)
if contentHash != "":
return some(contentHash)
except Exception as e:
@ -67,3 +119,39 @@ proc decodeENSContentHash*(value: string): tuple[ensType: ENSType, output: strin
return (ENSType.IPNS, parseHexStr(value[12..value.len-1]))
return (ENSType.UNKNOWN, "")
const pubkey_signature = "0xc8690233" # pubkey(bytes32 node)
proc pubkey*(username: string): string =
var userNameHash = namehash(addDomain(username))
userNameHash.removePrefix("0x")
let ensResolver = resolver(userNameHash)
let payload = %* [{
"to": ensResolver,
"from": "0x0000000000000000000000000000000000000000",
"data": fmt"{pubkey_signature}{userNameHash}"
}, "latest"]
let response = status_eth.doEthCall(payload)
# TODO: error handling
var pubkey = response.result.getStr()
if pubkey == "0x" or pubkey == "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":
result = ""
else:
pubkey.removePrefix("0x")
result = "0x04" & pubkey
const address_signature = "0x3b3b57de" # addr(bytes32 node)
proc address*(username: string): string =
var userNameHash = namehash(addDomain(username))
userNameHash.removePrefix("0x")
let ensResolver = resolver(userNameHash)
let payload = %* [{
"to": ensResolver,
"from": "0x0000000000000000000000000000000000000000",
"data": fmt"{address_signature}{userNameHash}"
}, "latest"]
let response = status_eth.doEthCall(payload)
# TODO: error handling
let address = response.result.getStr()
if address == "0x0000000000000000000000000000000000000000000000000000000000000000":
return ""
result = "0x" & address.substr(26)

View File

@ -4,8 +4,11 @@ import
import
web3/ethtypes, stew/byteutils, nimcrypto, json_serialization, chronicles
import json, tables, json_serialization
import web3/[ethtypes, conversions], stint
import ./method_dto
import status/statusgo_backend_new/eth as status_eth
include ../../../common/json_utils
type
@ -33,3 +36,37 @@ proc newErc20Contract*(chainId: int, address: Address): Erc20ContractDto =
proc newErc721Contract*(name: string, chainId: int, address: Address, symbol: string, hasIcon: bool, addlMethods: seq[tuple[name: string, meth: MethodDto]] = @[]): Erc721ContractDto =
Erc721ContractDto(name: name, chainId: chainId, address: address, symbol: symbol, hasIcon: hasIcon, methods: ERC721_ENUMERABLE_METHODS.concat(addlMethods).toTable)
proc tokenDecimals*(contract: ContractDto): int =
let payload = %* [{
"to": $contract.address,
"data": contract.methods["decimals"].encodeAbi()
}, "latest"]
let response = status_eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting token decimals: " & response.error.message)
if response.result.getStr == "0x":
return 0
result = parseHexInt(response.result.getStr)
proc getTokenString*(contract: ContractDto, methodName: string): string =
let payload = %* [{
"to": $contract.address,
"data": contract.methods[methodName].encodeAbi()
}, "latest"]
let response = status_eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting token string - " & methodName & ": " & response.error.message)
if response.result.getStr == "0x":
return ""
let size = fromHex(Stuint[256], response.result.getStr[66..129]).truncate(int)
result = response.result.getStr[130..129+size*2].parseHexStr
proc tokenName*(contract: ContractDto): string =
getTokenString(contract, "name")
proc tokenSymbol*(contract: ContractDto): string =
getTokenString(contract, "symbol")

View File

@ -6,16 +6,11 @@ import
import status/statusgo_backend_new/eth as status_eth
import
status/types/rpc_response,
status/statusgo_backend/eth
import
./transaction,
./coder
type MethodDto* = object
name*: string
signature*: string
@ -83,8 +78,9 @@ proc estimateGas*(self: MethodDto, tx: var TransactionDataDto, methodDescriptor:
success = true
tx.data = self.encodeAbi(methodDescriptor)
try:
let response = eth.estimateGas(%*[%tx])
result = response.result # gas estimate in hex
# this call should not be part of this file, we need to move it to appropriate place, or this should not be a DTO class.
let response = status_eth.estimateGas(%*[%tx])
result = response.result.getStr # gas estimate in hex
except RpcException as e:
success = false
result = e.msg
@ -95,15 +91,17 @@ proc getEstimateGasData*(self: MethodDto, tx: var TransactionDataDto, methodDesc
proc send*(self: MethodDto, tx: var TransactionDataDto, methodDescriptor: object, password: string, success: var bool): string =
tx.data = self.encodeAbi(methodDescriptor)
# this call should not be part of this file, we need to move it to appropriate place, or this should not be a DTO class.
let response = status_eth.sendTransaction($(%tx), password)
return $response.result
proc call*[T](self: MethodDto, tx: var TransactionDataDto, methodDescriptor: object, success: var bool): T =
proc call[T](self: MethodDto, tx: var TransactionDataDto, methodDescriptor: object, success: var bool): T =
success = true
tx.data = self.encodeAbi(methodDescriptor)
let response: RpcResponse
try:
response = eth.call(tx)
# this call should not be part of this file, we need to move it to appropriate place, or this should not be a DTO class.
response = status_eth.doEthCall(tx)
except RpcException as e:
success = false
result = e.msg

View File

@ -1,25 +1,9 @@
import strutils, json
import web3/ethtypes, web3/conversions, options, stint
import ../utils
type
TransactionDto* = ref object
id*: string
typeValue*: string
address*: string
blockNumber*: string
blockHash*: string
contract*: string
timestamp*: string
gasPrice*: string
gasLimit*: string
gasUsed*: string
nonce*: string
txStatus*: string
value*: string
fromAddress*: string
to*: string
type PendingTransactionTypeDto* {.pure.} = enum
PendingTransactionTypeDto* {.pure.} = enum
RegisterENS = "RegisterENS",
SetPubKey = "SetPubKey",
ReleaseENS = "ReleaseENS",
@ -39,21 +23,6 @@ type
nonce*: Option[Nonce] # (optional) integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
txType*: string
proc cmpTransactions*(x, y: TransactionDto): int =
# Sort proc to compare transactions from a single account.
# Compares first by block number, then by nonce
result = cmp(x.blockNumber.parseHexInt, y.blockNumber.parseHexInt)
if result == 0:
result = cmp(x.nonce, y.nonce)
# TODO: make this public in nim-web3 lib
template stripLeadingZeros*(value: string): string =
var cidx = 0
# ignore the last character so we retain '0' on zero value
while cidx < value.len - 1 and value[cidx] == '0':
cidx.inc
value[cidx .. ^1]
proc `%`*(x: TransactionDataDto): JsonNode =
result = newJobject()
result["from"] = %x.source

View File

@ -1,12 +1,9 @@
import json, sequtils, chronicles, macros, sugar, strutils, stint
import
web3/ethtypes, json_serialization, chronicles, tables
import web3/ethtypes, json_serialization, chronicles, tables
import status/statusgo_backend_new/eth
# TODO remove those
import status/utils
import utils
import ./dto/contract
import ./dto/method_dto
import ./dto/network

View File

@ -237,3 +237,11 @@ proc isUnique*[T](key: T, existingKeys: var seq[T]): bool =
proc deduplicate*[T](txs: var seq[T], key: (T) -> string) =
var existingKeys: seq[string] = @[]
txs.keepIf(tx => tx.key().isUnique(existingKeys))
# TODO: make this public in nim-web3 lib
proc stripLeadingZeros*(value: string): string =
var cidx = 0
# ignore the last character so we retain '0' on zero value
while cidx < value.len - 1 and value[cidx] == '0':
cidx.inc
value[cidx .. ^1]

View File

@ -0,0 +1,43 @@
import json, chronicles
import service_interface
import status/statusgo_backend_new/general as status_general
import status/statusgo_backend_new/keycard as status_keycard
import ../../../constants as app_constants
export service_interface
logScope:
topics = "general-app-service"
type
Service* = ref object of service_interface.ServiceInterface
method delete*(self: Service) =
discard
proc newService*(): Service =
result = Service()
method initKeycard(self: Service) =
## This should not be part of the "general service", but part of the "keystore service", but since we don't have
## keycard in place for the refactored part yet but `status-go` part requires keycard to be initialized on the app
## start. This call is added as a part of the "global service".
try:
discard status_keycard.initKeycard(app_constants.KEYSTOREDIR)
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
method init*(self: Service) =
self.initKeycard()
method startMessenger*(self: Service) =
try:
discard status_general.startMessenger()
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return

View File

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

View File

@ -1,6 +1,6 @@
import NimQml, chronicles
import eventemitter
import ../../../app/core/eventemitter
logScope:
topics = "keychain-service"

View File

@ -9,8 +9,6 @@ import ../settings/service_interface as settings_service
import ../node_configuration/service_interface as node_configuration_service
import status/statusgo_backend_new/mailservers as status_mailservers
import eventemitter
logScope:
topics = "mailservers-service"

View File

@ -0,0 +1,14 @@
{.used.}
import json
include ../../../common/json_utils
type RemovedMessageDto* = object
chatId*: string
messageId*: string
proc toRemovedMessageDto*(jsonObj: JsonNode): RemovedMessageDto =
result = RemovedMessageDto()
discard jsonObj.getProp("chatId", result.chatId)
discard jsonObj.getProp("messageId", result.messageId)

View File

@ -1,9 +1,8 @@
import NimQml, tables, json, sequtils, chronicles
import eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ../../../app/core/signals/types
import ../../../app/core/eventemitter
import status/statusgo_backend_new/messages as status_go
import ./dto/message as message_dto

View File

@ -1,9 +1,8 @@
import NimQml, chronicles, strutils, json, nimcrypto
import status/utils
import eventemitter
import ../settings/service as settings_service
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ../../../app/core/fleets/fleet_configuration

View File

@ -1,6 +1,7 @@
import NimQml, json, chronicles
import details
import eventemitter
import ../../../app/core/eventemitter
logScope:
topics = "os-notification-service"

View File

@ -3,12 +3,12 @@ import NimQml, json, strutils, chronicles
import ../settings/service_interface as settings_service
import ../accounts/service_interface as accounts_service
import ../../../app/core/eventemitter
import status/statusgo_backend_new/accounts as status_account
import status/statusgo_backend_new/eth as status_eth
import status/statusgo_backend_new/privacy as status_privacy
import eventemitter
logScope:
topics = "privacy-service"

View File

@ -1,6 +1,8 @@
import chronicles, sequtils, json
import eventemitter
import ./service_interface, ./dto
import ../../../app/core/eventemitter
import status/statusgo_backend_new/saved_addresses as backend
export service_interface

View File

@ -1,7 +1,7 @@
import NimQml, Tables, json, sequtils, chronicles, strutils, atomics, sets, strutils, tables, stint
import httpclient
import eventemitter
import ../../../app/core/[main]
import ../../../app/core/tasks/[qt, threadpool]

View File

@ -1,7 +1,8 @@
# include strformat, json
include ../../common/json_utils
include ../../../app/core/tasks/common
import status/[utils, tokens]
import ../eth/dto/contract
import ../eth/utils
#################################################
# Async load transactions

View File

@ -1,10 +1,12 @@
import NimQml, json, sequtils, chronicles, strformat, strutils
import eventemitter
from sugar import `=>`
import web3/ethtypes
from web3/conversions import `$`
import status/statusgo_backend_new/custom_tokens as custom_tokens
import ../settings/service_interface as settings_service
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ./dto, ./static_token

View File

@ -1,5 +1,6 @@
include ../../common/json_utils
include ../../../app/core/tasks/common
import strutils
#################################################
# Async load transactions
@ -15,9 +16,10 @@ type
const loadTransactionsTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let
arg = decode[LoadTransactionsTaskArg](argEncoded)
limitAsHex = "0x" & eth_utils.stripLeadingZeros(arg.limit.toHex)
output = %*{
"address": arg.address,
"history": transactions.getTransfersByAddress(arg.address, arg.toBlock, arg.limit, arg.loadMore),
"history": transactions.getTransfersByAddress(arg.address, arg.toBlock, limitAsHex, arg.loadMore),
"loadMore": arg.loadMore
}
arg.finish(output)

View File

@ -36,3 +36,11 @@ proc toTransactionDto*(jsonObj: JsonNode): TransactionDto =
discard jsonObj.getProp("value", result.value)
discard jsonObj.getProp("from", result.fromAddress)
discard jsonObj.getProp("to", result.to)
proc cmpTransactions*(x, y: TransactionDto): int =
# Sort proc to compare transactions from a single account.
# Compares first by block number, then by nonce
result = cmp(x.blockNumber.parseHexInt, y.blockNumber.parseHexInt)
if result == 0:
result = cmp(x.nonce, y.nonce)

View File

@ -1,13 +1,12 @@
import NimQml, chronicles, sequtils, sugar, stint, json
import status/statusgo_backend_new/transactions as transactions
import status/statusgo_backend/wallet
import eventemitter
import status/statusgo_backend_new/wallet as status_wallet
import ../../../app/core/[main]
import ../../../app/core/tasks/[qt, threadpool]
import ../wallet_account/service as wallet_account_service
import ./service_interface, ./dto
import ../eth/utils as eth_utils
export service_interface
@ -54,11 +53,20 @@ QtObject:
return
proc getPendingTransactions*(self: Service): string =
wallet.getPendingTransactions()
try:
# this may be improved (need to add some checkings) but due to removing `status-lib` dependencies, channges made
# in this go are as minimal as possible
let response = status_wallet.getPendingTransactions()
return response.result.getStr
except Exception as e:
let errDesription = e.msg
error "error: ", errDesription
return
proc getTransfersByAddress*(self: Service, address: string, toBlock: Uint256, limit: int, loadMore: bool = false): seq[TransactionDto] =
try:
let response = transactions.getTransfersByAddress(address, toBlock, limit, loadMore)
let limitAsHex = "0x" & eth_utils.stripLeadingZeros(limit.toHex)
let response = transactions.getTransfersByAddress(address, toBlock, limitAsHex, loadMore)
result = map(
response.result.getElems(),

View File

@ -1,6 +1,5 @@
import Tables, json, sequtils, sugar, chronicles, strformat, stint, httpclient, net, strutils
import web3/[ethtypes, conversions]
import eventemitter
import ../settings/service_interface as settings_service
import ../accounts/service_interface as accounts_service
@ -8,6 +7,8 @@ import ../token/service as token_service
import ../../common/account_constants
import ./service_interface, ./dto
import ../../../app/core/eventemitter
import status/statusgo_backend_new/accounts as status_go_accounts
import status/statusgo_backend_new/eth as status_go_eth