2021-09-08 18:05:39 +00:00
|
|
|
import json, json_serialization
|
|
|
|
|
2021-09-11 21:50:36 +00:00
|
|
|
import statusgo_backend/settings as statusgo_backend_settings
|
2021-09-08 18:05:39 +00:00
|
|
|
import ../eventemitter
|
2021-09-09 21:36:28 +00:00
|
|
|
import ./types/[fleet, network_type, setting, rpc_response]
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
SettingsModel* = ref object
|
|
|
|
events*: EventEmitter
|
|
|
|
|
|
|
|
proc newSettingsModel*(events: EventEmitter): SettingsModel =
|
|
|
|
result = SettingsModel()
|
|
|
|
result.events = events
|
|
|
|
|
|
|
|
proc saveSetting*(self: SettingsModel, key: Setting, value: string | JsonNode | bool): StatusGoError =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.saveSetting(key, value)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getSetting*[T](self: SettingsModel, name: Setting, defaultValue: T, useCached: bool = true): T =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getSetting(name, defaultValue, useCached)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getSetting*[T](self: SettingsModel, name: Setting, useCached: bool = true): T =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getSetting[T](name, useCached)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getCurrentNetworkDetails*(self: SettingsModel): NetworkDetails =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getCurrentNetworkDetails()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getMailservers*(self: SettingsModel):JsonNode =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getMailservers()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getPinnedMailserver*(self: SettingsModel): string =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getPinnedMailserver()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc pinMailserver*(self: SettingsModel, enode: string = "") =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.pinMailserver(enode)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc saveMailserver*(self: SettingsModel, name, enode: string) =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.saveMailserver(name, enode)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc getFleet*(self: SettingsModel): Fleet =
|
2021-09-11 21:50:36 +00:00
|
|
|
result = statusgo_backend_settings.getFleet()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
2021-09-09 21:36:28 +00:00
|
|
|
proc getCurrentNetwork*(self: SettingsModel): NetworkType =
|
2021-09-29 19:12:49 +00:00
|
|
|
result = statusgo_backend_settings.getCurrentNetwork()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc setWakuVersion*(self: SettingsModel, newVersion: int) =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.setWakuVersion(newVersion)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
2021-09-30 18:56:22 +00:00
|
|
|
proc getWakuVersion*(self: SettingsModel): int =
|
|
|
|
statusgo_backend_settings.getWakuVersion()
|
|
|
|
|
2021-09-08 18:05:39 +00:00
|
|
|
proc setBloomFilterMode*(self: SettingsModel, bloomFilterMode: bool): StatusGoError =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.setBloomFilterMode(bloomFilterMode)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc setFleet*(self: SettingsModel, fleetConfig: FleetConfig, fleet: Fleet): StatusGoError =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.setFleet(fleetConfig, fleet)
|
2021-09-08 18:05:39 +00:00
|
|
|
|
2021-09-30 18:56:22 +00:00
|
|
|
proc setV2LightMode*(self: SettingsModel, enabled: bool): StatusGoError =
|
|
|
|
statusgo_backend_settings.setV2LightMode(enabled)
|
|
|
|
|
2021-09-08 18:05:39 +00:00
|
|
|
proc getNodeConfig*(self: SettingsModel): JsonNode =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.getNodeConfig()
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
proc setBloomLevel*(self: SettingsModel, bloomFilterMode: bool, fullNode: bool): StatusGoError =
|
2021-09-11 21:50:36 +00:00
|
|
|
statusgo_backend_settings.setBloomLevel(bloomFilterMode, fullNode)
|