fix(@wallet): update network form
This commit is contained in:
parent
fddcc3a83f
commit
3e985e62e1
|
@ -70,7 +70,9 @@ proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
|||
layer: network.layer,
|
||||
chainName: network.chainName,
|
||||
rpcURL: network.rpcURL,
|
||||
originalRpcURL: network.originalRpcURL,
|
||||
fallbackURL: network.fallbackURL,
|
||||
originalFallbackURL: network.originalFallbackURL,
|
||||
blockExplorerURL: network.blockExplorerURL,
|
||||
iconURL: network.iconURL,
|
||||
nativeCurrencyName: network.nativeCurrencyName,
|
||||
|
|
|
@ -40,7 +40,9 @@ type
|
|||
layer* {.serializedFieldName("layer").}: int
|
||||
chainName* {.serializedFieldName("chainName").}: string
|
||||
rpcURL* {.serializedFieldName("rpcUrl").}: string
|
||||
originalRpcURL* {.serializedFieldName("originalRpcUrl").}: string
|
||||
fallbackURL* {.serializedFieldName("fallbackUrl").}: string
|
||||
originalFallbackURL* {.serializedFieldName("originalFallbackURL").}: string
|
||||
blockExplorerURL* {.serializedFieldName("blockExplorerUrl").}: string
|
||||
iconURL* {.serializedFieldName("iconUrl").}: string
|
||||
nativeCurrencyName* {.serializedFieldName("nativeCurrencyName").}: string
|
||||
|
|
|
@ -46,8 +46,8 @@ ColumnLayout {
|
|||
d.evaluationStatusMainRpc = EditNetworkForm.UnTouched
|
||||
d.evaluationStatusFallBackRpc = EditNetworkForm.UnTouched
|
||||
if(!!network) {
|
||||
mainRpcInput.text = network.rpcURL
|
||||
failoverRpcUrlInput.text = network.fallbackURL
|
||||
mainRpcInput.text = d.mask(network.originalRpcURL)
|
||||
failoverRpcUrlInput.text = d.mask(network.originalFallbackURL)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,13 @@ ColumnLayout {
|
|||
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()}
|
||||
|
@ -163,7 +170,7 @@ ColumnLayout {
|
|||
return ""
|
||||
}
|
||||
if (network.originalRpcURL === network.rpcURL) {
|
||||
return network.rpcURL.replace(/(.*\/).*/, '$1')
|
||||
return d.mask(network.rpcURL)
|
||||
}
|
||||
return network.rpcURL
|
||||
}
|
||||
|
@ -172,9 +179,12 @@ ColumnLayout {
|
|||
d.evaluationStatusMainRpc = EditNetworkForm.Empty
|
||||
return
|
||||
}
|
||||
if(!!text &&
|
||||
(network.originalRpcURL === network.rpcURL && text !== network.rpcURL.replace(/(.*\/).*/, '$1')) ||
|
||||
(network.originalRpcURL !== network.rpcURL && text !== network.rpcURL)) {
|
||||
|
||||
if (!!text && d.mask(network.originalRpcURL) === text) {
|
||||
d.evaluationStatusMainRpc = EditNetworkForm.Verified
|
||||
}
|
||||
|
||||
if(!!text && d.mask(network.originalRpcURL) !== text) {
|
||||
d.evaluationStatusMainRpc = EditNetworkForm.Pending
|
||||
Qt.callLater(d.evaluateRpcEndPoint, text, true);
|
||||
}
|
||||
|
@ -201,7 +211,7 @@ ColumnLayout {
|
|||
return ""
|
||||
}
|
||||
if (network.originalFallbackURL === network.fallbackURL) {
|
||||
return network.fallbackURL.replace(/(.*\/).*/, '$1')
|
||||
return d.mask(network.fallbackURL)
|
||||
}
|
||||
return network.fallbackURL
|
||||
}
|
||||
|
@ -211,9 +221,11 @@ ColumnLayout {
|
|||
return
|
||||
}
|
||||
|
||||
if(!!text &&
|
||||
(network.originalFallbackURL === network.fallbackURL && text !== network.fallbackURL.replace(/(.*\/).*/, '$1')) ||
|
||||
(network.originalFallbackURL !== network.fallbackURL && text !== network.fallbackURL)) {
|
||||
if (!!text && d.mask(network.originalFallbackURL) === text) {
|
||||
d.evaluationStatusFallBackRpc = EditNetworkForm.Verified
|
||||
}
|
||||
|
||||
if(!!text && d.mask(network.originalFallbackURL) !== text) {
|
||||
d.evaluationStatusFallBackRpc = EditNetworkForm.Pending
|
||||
Qt.callLater(d.evaluateRpcEndPoint, text, false);
|
||||
}
|
||||
|
@ -247,7 +259,6 @@ ColumnLayout {
|
|||
StatusButton {
|
||||
text: qsTr("Revert to default")
|
||||
normalColor: "transparent"
|
||||
enabled: d.evaluationStatusMainRpc !== EditNetworkForm.UnTouched || d.evaluationStatusFallBackRpc !== EditNetworkForm.UnTouched
|
||||
onClicked: d.revertValues()
|
||||
}
|
||||
StatusButton {
|
||||
|
@ -260,7 +271,18 @@ ColumnLayout {
|
|||
d.evaluationStatusFallBackRpc === EditNetworkForm.Empty
|
||||
) && 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4cab5b61060a00ad6878d09a2f8f1e2a73bb21f5
|
||||
Subproject commit 57c7054dd2831386cbf1a67caf3ce25ad5d99691
|
Loading…
Reference in New Issue