(feat/desktop) Add toggle for mainnet transaction validation with nimbus (#13227)

- Adds the View for the toogle button
This commit is contained in:
Godfrain Jacques 2024-02-20 11:07:22 -08:00 committed by GitHub
parent 7736cd8950
commit f236782490
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 102 additions and 0 deletions

View File

@ -116,6 +116,18 @@ proc toggleDebug*(self: Controller) =
self.delegate.onDebugToggled()
proc isNimbusProxyEnabled*(self: Controller): bool =
return self.nodeConfigurationService.isNimbusProxyEnabled()
proc toggleNimbusProxy*(self: Controller) =
let enabled = self.nodeConfigurationService.isNimbusProxyEnabled()
if(not self.nodeConfigurationService.setNimbusProxyConfig(not enabled)):
error "an error occurred, we couldn't toggle nimbus proxy"
return
self.delegate.onNimbusProxyToggled()
proc toggleCommunitiesPortalSection*(self: Controller) =
self.events.emit(TOGGLE_SECTION, ToggleSectionArgs(sectionType: SectionType.CommunitiesPortal))

View File

@ -30,6 +30,9 @@ method onAutoMessageToggled*(self: AccessInterface) {.base.} =
method onDebugToggled*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onNimbusProxyToggled*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
@ -69,6 +72,12 @@ method isRuntimeLogLevelSet*(self: AccessInterface): bool {.base.} =
method toggleDebug*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method isNimbusProxyEnabled*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method toggleNimbusProxy*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleCommunitiesPortalSection*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -105,6 +105,15 @@ method toggleDebug*(self: Module) =
method onDebugToggled*(self: Module) =
self.view.isDebugEnabledChanged()
method isNimbusProxyEnabled*(self: Module): bool =
self.controller.isNimbusProxyEnabled()
method toggleNimbusProxy*(self: Module) =
self.controller.toggleNimbusProxy()
method onNimbusProxyToggled*(self: Module) =
self.view.isNimbusProxyEnabledChanged()
method isRuntimeLogLevelSet*(self: Module): bool =
return constants.runtimeLogLevelSet()

View File

@ -88,6 +88,16 @@ QtObject:
proc toggleDebug*(self: View) {.slot.} =
self.delegate.toggleDebug()
proc isNimbusProxyEnabledChanged*(self: View) {.signal.}
proc getIsNimbusProxyEnabled*(self: View): bool {.slot.} =
return self.delegate.isNimbusProxyEnabled()
QtProperty[bool] isNimbusProxyEnabled:
read = getIsNimbusProxyEnabled
notify = isNimbusProxyEnabledChanged
proc toggleNimbusProxy*(self: View) {.slot.} =
self.delegate.toggleNimbusProxy()
proc getIsRuntimeLogLevelSet*(self: View): bool {.slot.} =
return self.delegate.isRuntimeLogLevelSet()
QtProperty[bool] isRuntimeLogLevelSet:

View File

@ -107,6 +107,9 @@ type
EnableFilterFullNode*: bool
UseShardAsDefaultTopic*: bool
NimbusProxyConfig* = object
Enabled*: bool
ShhextConfig* = object
PFSEnabled*: bool
BackupDisabledDataDir*: string
@ -230,11 +233,15 @@ type
RequireTopics*: RequireTopics
MailServerRegistryAddress*: string
PushNotificationServerConfig*: PushNotificationServerConfig # not used in the app yet
NimbusProxyConfig*: NimbusProxyConfig
proc toUpstreamConfig*(jsonObj: JsonNode): UpstreamConfig =
discard jsonObj.getProp("Enabled", result.Enabled)
discard jsonObj.getProp("URL", result.URL)
proc toNimbusProxyConfig*(jsonObj: JsonNode): NimbusProxyConfig =
discard jsonObj.getProp("Enabled", result.Enabled)
proc toNetwork*(jsonObj: JsonNode): Network =
discard jsonObj.getProp("chainId", result.chainId)
discard jsonObj.getProp("chainName", result.chainName)
@ -484,6 +491,10 @@ proc toNodeConfigDto*(jsonObj: JsonNode): NodeConfigDto =
discard jsonObj.getProp("EnableNTPSync", result.EnableNTPSync)
discard jsonObj.getProp("MailServerRegistryAddress", result.MailServerRegistryAddress)
var nimbusProxyConfigObj: JsonNode
if(jsonObj.getProp("NimbusProxyConfig", nimbusProxyConfigObj)):
result.NimbusProxyConfig = toNimbusProxyConfig(nimbusProxyConfigObj)
var upstreamConfigObj: JsonNode
if(jsonObj.getProp("UpstreamConfig", upstreamConfigObj)):
result.UpstreamConfig = toUpstreamConfig(upstreamConfigObj)

View File

@ -211,6 +211,17 @@ proc setLogLevel*(self: Service, logLevel: LogLevel): bool =
else:
return false
proc getNimbusProxyConfig(self: Service): bool =
return self.configuration.NimbusProxyConfig.Enabled
proc isNimbusProxyEnabled*(self: Service): bool =
return self.getNimbusProxyConfig()
proc setNimbusProxyConfig*(self: Service, value: bool): bool =
var newConfiguration = self.configuration
newConfiguration.NimbusProxyConfig.Enabled = value
return self.saveConfiguration(newConfiguration)
proc isV2LightMode*(self: Service): bool =
return self.configuration.WakuV2Config.LightClient

View File

@ -13,6 +13,7 @@ QtObject {
property bool wakuV2LightClientEnabled: advancedModule? advancedModule.wakuV2LightClientEnabled : false
property bool isTelemetryEnabled: advancedModule? advancedModule.isTelemetryEnabled : false
property bool isAutoMessageEnabled: advancedModule? advancedModule.isAutoMessageEnabled : false
property bool isNimbusProxyEnabled: advancedModule? advancedModule.isNimbusProxyEnabled : false
property bool isDebugEnabled: advancedModule? advancedModule.isDebugEnabled : false
readonly property bool isWakuV2ShardedCommunitiesEnabled: localAppSettings.wakuV2ShardedCommunitiesEnabled ?? false
property int logMaxBackups: advancedModule ? advancedModule.logMaxBackups : 1
@ -89,6 +90,13 @@ QtObject {
root.advancedModule.toggleDebug()
}
function toggleNimbusProxy() {
if(!root.advancedModule)
return
root.advancedModule.toggleNimbusProxy()
}
function setMaxLogBackups(value) {
if(!root.advancedModule)
return

View File

@ -82,6 +82,17 @@ SettingsContentBase {
}
}
StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
text: qsTr("Mainnet data verified by Nimbus")
isSwitch: true
switchChecked: root.advancedStore.isNimbusProxyEnabled
onClicked: {
Global.openPopup(enableNimbusProxyComponent)
}
}
StatusBaseText {
anchors.left: parent.left
anchors.right: parent.right
@ -551,6 +562,27 @@ SettingsContentBase {
}
}
Component {
id: enableNimbusProxyComponent
ConfirmationDialog {
property bool mode: false
id: confirmDialog
destroyOnClose: true
showCancelButton: true
confirmationText: qsTr("Are you sure you want to %1 Nimbus proxy? You need to restart the app for this change to take effect.").arg(root.advancedStore.isNimbusProxyEnabled ?
qsTr("disable") :
qsTr("enable"))
onConfirmButtonClicked: {
root.advancedStore.toggleNimbusProxy()
close()
}
onCancelButtonClicked: {
close()
}
}
}
Component {
id: changeNumberOfLogsArchived