status-lib/status/settings.nim

64 lines
2.5 KiB
Nim
Raw Normal View History

2021-09-08 18:05:39 +00:00
import json, json_serialization
import statusgo_backend/settings as statusgo_backend_settings
2021-09-08 18:05:39 +00:00
import ../eventemitter
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 =
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 =
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 =
result = statusgo_backend_settings.getSetting[T](name, useCached)
2021-09-08 18:05:39 +00:00
proc getCurrentNetworkDetails*(self: SettingsModel): NetworkDetails =
result = statusgo_backend_settings.getCurrentNetworkDetails()
2021-09-08 18:05:39 +00:00
proc getMailservers*(self: SettingsModel):JsonNode =
result = statusgo_backend_settings.getMailservers()
2021-09-08 18:05:39 +00:00
proc getPinnedMailserver*(self: SettingsModel): string =
result = statusgo_backend_settings.getPinnedMailserver()
2021-09-08 18:05:39 +00:00
proc pinMailserver*(self: SettingsModel, enode: string = "") =
statusgo_backend_settings.pinMailserver(enode)
2021-09-08 18:05:39 +00:00
proc saveMailserver*(self: SettingsModel, name, enode: string) =
statusgo_backend_settings.saveMailserver(name, enode)
2021-09-08 18:05:39 +00:00
proc getFleet*(self: SettingsModel): Fleet =
result = statusgo_backend_settings.getFleet()
2021-09-08 18:05:39 +00:00
proc getCurrentNetwork*(self: SettingsModel): NetworkType =
result = statusgo_backend_settings.getCurrentNetwork()
2021-09-08 18:05:39 +00:00
proc setWakuVersion*(self: SettingsModel, newVersion: int) =
statusgo_backend_settings.setWakuVersion(newVersion)
2021-09-08 18:05:39 +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 =
statusgo_backend_settings.setBloomFilterMode(bloomFilterMode)
2021-09-08 18:05:39 +00:00
proc setFleet*(self: SettingsModel, fleetConfig: FleetConfig, fleet: Fleet): StatusGoError =
statusgo_backend_settings.setFleet(fleetConfig, fleet)
2021-09-08 18:05:39 +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 =
statusgo_backend_settings.getNodeConfig()
2021-09-08 18:05:39 +00:00
proc setBloomLevel*(self: SettingsModel, bloomFilterMode: bool, fullNode: bool): StatusGoError =
statusgo_backend_settings.setBloomLevel(bloomFilterMode, fullNode)