fix(@wallet): update network form

This commit is contained in:
Anthony Laibe 2023-09-19 13:42:25 +02:00
parent fddcc3a83f
commit 3e985e62e1
4 changed files with 39 additions and 13 deletions

View File

@ -70,7 +70,9 @@ proc upsertNetwork*(self: Service, network: NetworkDto): bool =
layer: network.layer, layer: network.layer,
chainName: network.chainName, chainName: network.chainName,
rpcURL: network.rpcURL, rpcURL: network.rpcURL,
originalRpcURL: network.originalRpcURL,
fallbackURL: network.fallbackURL, fallbackURL: network.fallbackURL,
originalFallbackURL: network.originalFallbackURL,
blockExplorerURL: network.blockExplorerURL, blockExplorerURL: network.blockExplorerURL,
iconURL: network.iconURL, iconURL: network.iconURL,
nativeCurrencyName: network.nativeCurrencyName, nativeCurrencyName: network.nativeCurrencyName,

View File

@ -40,7 +40,9 @@ type
layer* {.serializedFieldName("layer").}: int layer* {.serializedFieldName("layer").}: int
chainName* {.serializedFieldName("chainName").}: string chainName* {.serializedFieldName("chainName").}: string
rpcURL* {.serializedFieldName("rpcUrl").}: string rpcURL* {.serializedFieldName("rpcUrl").}: string
originalRpcURL* {.serializedFieldName("originalRpcUrl").}: string
fallbackURL* {.serializedFieldName("fallbackUrl").}: string fallbackURL* {.serializedFieldName("fallbackUrl").}: string
originalFallbackURL* {.serializedFieldName("originalFallbackURL").}: string
blockExplorerURL* {.serializedFieldName("blockExplorerUrl").}: string blockExplorerURL* {.serializedFieldName("blockExplorerUrl").}: string
iconURL* {.serializedFieldName("iconUrl").}: string iconURL* {.serializedFieldName("iconUrl").}: string
nativeCurrencyName* {.serializedFieldName("nativeCurrencyName").}: string nativeCurrencyName* {.serializedFieldName("nativeCurrencyName").}: string

View File

@ -46,8 +46,8 @@ ColumnLayout {
d.evaluationStatusMainRpc = EditNetworkForm.UnTouched d.evaluationStatusMainRpc = EditNetworkForm.UnTouched
d.evaluationStatusFallBackRpc = EditNetworkForm.UnTouched d.evaluationStatusFallBackRpc = EditNetworkForm.UnTouched
if(!!network) { if(!!network) {
mainRpcInput.text = network.rpcURL mainRpcInput.text = d.mask(network.originalRpcURL)
failoverRpcUrlInput.text = network.fallbackURL failoverRpcUrlInput.text = d.mask(network.originalFallbackURL)
} }
} }
@ -88,6 +88,13 @@ ColumnLayout {
default: return Text.AlignRight default: return Text.AlignRight
} }
} }
function mask(rpcUrl) {
// Mask the last part of the URL
return rpcUrl.replace(/(\/)([^\/]+)$/, (match, p1, p2) => {
return p1 + p2.replace(/./g, '*');
});
}
} }
onVisibleChanged: if(!visible) {d.revertValues()} onVisibleChanged: if(!visible) {d.revertValues()}
@ -163,7 +170,7 @@ ColumnLayout {
return "" return ""
} }
if (network.originalRpcURL === network.rpcURL) { if (network.originalRpcURL === network.rpcURL) {
return network.rpcURL.replace(/(.*\/).*/, '$1') return d.mask(network.rpcURL)
} }
return network.rpcURL return network.rpcURL
} }
@ -172,9 +179,12 @@ ColumnLayout {
d.evaluationStatusMainRpc = EditNetworkForm.Empty d.evaluationStatusMainRpc = EditNetworkForm.Empty
return return
} }
if(!!text &&
(network.originalRpcURL === network.rpcURL && text !== network.rpcURL.replace(/(.*\/).*/, '$1')) || if (!!text && d.mask(network.originalRpcURL) === text) {
(network.originalRpcURL !== network.rpcURL && text !== network.rpcURL)) { d.evaluationStatusMainRpc = EditNetworkForm.Verified
}
if(!!text && d.mask(network.originalRpcURL) !== text) {
d.evaluationStatusMainRpc = EditNetworkForm.Pending d.evaluationStatusMainRpc = EditNetworkForm.Pending
Qt.callLater(d.evaluateRpcEndPoint, text, true); Qt.callLater(d.evaluateRpcEndPoint, text, true);
} }
@ -201,7 +211,7 @@ ColumnLayout {
return "" return ""
} }
if (network.originalFallbackURL === network.fallbackURL) { if (network.originalFallbackURL === network.fallbackURL) {
return network.fallbackURL.replace(/(.*\/).*/, '$1') return d.mask(network.fallbackURL)
} }
return network.fallbackURL return network.fallbackURL
} }
@ -211,9 +221,11 @@ ColumnLayout {
return return
} }
if(!!text && if (!!text && d.mask(network.originalFallbackURL) === text) {
(network.originalFallbackURL === network.fallbackURL && text !== network.fallbackURL.replace(/(.*\/).*/, '$1')) || d.evaluationStatusFallBackRpc = EditNetworkForm.Verified
(network.originalFallbackURL !== network.fallbackURL && text !== network.fallbackURL)) { }
if(!!text && d.mask(network.originalFallbackURL) !== text) {
d.evaluationStatusFallBackRpc = EditNetworkForm.Pending d.evaluationStatusFallBackRpc = EditNetworkForm.Pending
Qt.callLater(d.evaluateRpcEndPoint, text, false); Qt.callLater(d.evaluateRpcEndPoint, text, false);
} }
@ -247,7 +259,6 @@ ColumnLayout {
StatusButton { StatusButton {
text: qsTr("Revert to default") text: qsTr("Revert to default")
normalColor: "transparent" normalColor: "transparent"
enabled: d.evaluationStatusMainRpc !== EditNetworkForm.UnTouched || d.evaluationStatusFallBackRpc !== EditNetworkForm.UnTouched
onClicked: d.revertValues() onClicked: d.revertValues()
} }
StatusButton { StatusButton {
@ -260,7 +271,18 @@ ColumnLayout {
d.evaluationStatusFallBackRpc === EditNetworkForm.Empty d.evaluationStatusFallBackRpc === EditNetworkForm.Empty
) && warningCheckbox.checked ) && warningCheckbox.checked
onClicked: root.updateNetworkValues(network.chainId, mainRpcInput.text, failoverRpcUrlInput.text) onClicked: {
let main = mainRpcInput.text
let fallback = failoverRpcUrlInput.text
if (main === d.mask(network.originalRpcURL)) {
main = network.originalRpcURL
}
if (fallback === d.mask(network.originalFallbackURL)) {
fallback = network.originalFallbackURL
}
root.updateNetworkValues(network.chainId, main, fallback)
}
} }
} }
} }

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 4cab5b61060a00ad6878d09a2f8f1e2a73bb21f5 Subproject commit 57c7054dd2831386cbf1a67caf3ce25ad5d99691