feat(@wallet): mask api keys

This commit is contained in:
Anthony Laibe 2023-08-17 11:38:10 +02:00
parent faf4933262
commit 678f751121
5 changed files with 53 additions and 5 deletions

View File

@ -10,6 +10,8 @@ QtObject:
chainColor: string chainColor: string
rpcURL: string rpcURL: string
fallbackURL: string fallbackURL: string
originalRpcURL: string
originalFallbackURL: string
blockExplorerURL: string blockExplorerURL: string
nativeCurrencySymbol: string nativeCurrencySymbol: string
@ -22,6 +24,8 @@ QtObject:
chainColor: string, chainColor: string,
rpcURL: string, rpcURL: string,
fallbackURL: string, fallbackURL: string,
originalRpcURL: string,
originalFallbackURL: string,
blockExplorerURL: string, blockExplorerURL: string,
nativeCurrencySymbol: string nativeCurrencySymbol: string
) = ) =
@ -34,6 +38,8 @@ QtObject:
self.chainColor = chainColor self.chainColor = chainColor
self.rpcURL = rpcURL self.rpcURL = rpcURL
self.fallbackURL = fallbackURL self.fallbackURL = fallbackURL
self.originalRpcURL = originalRpcURL
self.originalFallbackURL = originalFallbackURL
self.blockExplorerURL = blockExplorerURL self.blockExplorerURL = blockExplorerURL
self.nativeCurrencySymbol = nativeCurrencySymbol self.nativeCurrencySymbol = nativeCurrencySymbol
@ -49,11 +55,13 @@ QtObject:
chainColor: string, chainColor: string,
rpcURL: string, rpcURL: string,
fallbackURL: string, fallbackURL: string,
originalRpcURL: string,
originalFallbackURL: string,
blockExplorerURL: string, blockExplorerURL: string,
nativeCurrencySymbol: string nativeCurrencySymbol: string
): Item = ): Item =
new(result, delete) new(result, delete)
result.setup(chainId, layer, chainName, iconUrl, shortName, chainColor, rpcURL, fallbackURL, blockExplorerURL, nativeCurrencySymbol) result.setup(chainId, layer, chainName, iconUrl, shortName, chainColor, rpcURL, fallbackURL, originalRpcURL, originalFallbackURL, blockExplorerURL, nativeCurrencySymbol)
proc `$`*(self: Item): string = proc `$`*(self: Item): string =
result = fmt"""NetworkItem( result = fmt"""NetworkItem(
@ -125,6 +133,20 @@ QtObject:
read = fallbackURL read = fallbackURL
notify = fallbackURLChanged notify = fallbackURLChanged
proc originalRpcURLChanged*(self: Item) {.signal.}
proc originalRpcURL*(self: Item): string {.slot.} =
return self.originalRpcURL
QtProperty[string] originalRpcURL:
read = originalRpcURL
notify = originalRpcURLChanged
proc originalFallbackURLChanged*(self: Item) {.signal.}
proc originalFallbackURL*(self: Item): string {.slot.} =
return self.originalFallbackURL
QtProperty[string] originalFallbackURL:
read = originalFallbackURL
notify = originalFallbackURLChanged
proc blockExplorerURLChanged*(self: Item) {.signal.} proc blockExplorerURLChanged*(self: Item) {.signal.}
proc blockExplorerURL*(self: Item): string {.slot.} = proc blockExplorerURL*(self: Item): string {.slot.} =
return self.blockExplorerURL return self.blockExplorerURL

View File

@ -51,6 +51,8 @@ method refreshNetworks*(self: Module) =
n.prod.chainColor, n.prod.chainColor,
n.prod.rpcURL, n.prod.rpcURL,
n.prod.fallbackURL, n.prod.fallbackURL,
n.prod.originalRpcURL,
n.prod.originalFallbackURL,
n.prod.blockExplorerURL, n.prod.blockExplorerURL,
n.prod.nativeCurrencySymbol n.prod.nativeCurrencySymbol
) )
@ -63,6 +65,8 @@ method refreshNetworks*(self: Module) =
n.test.chainColor, n.test.chainColor,
n.test.rpcURL, n.test.rpcURL,
n.test.fallbackURL, n.test.fallbackURL,
n.test.originalRpcURL,
n.test.originalFallbackURL,
n.test.blockExplorerURL, n.test.blockExplorerURL,
n.test.nativeCurrencySymbol n.test.nativeCurrencySymbol
) )

View File

@ -9,7 +9,9 @@ type NetworkDto* = ref object
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

@ -129,6 +129,8 @@ QtObject {
chainColor: combinedNetwork.prod.chainColor, chainColor: combinedNetwork.prod.chainColor,
rpcURL: combinedNetwork.prod.rpcURL, rpcURL: combinedNetwork.prod.rpcURL,
fallbackURL: combinedNetwork.prod.fallbackURL, fallbackURL: combinedNetwork.prod.fallbackURL,
originalRpcURL: combinedNetwork.prod.originalRpcURL,
originalFallbackURL: combinedNetwork.prod.originalFallbackURL,
blockExplorerURL: combinedNetwork.prod.blockExplorerURL, blockExplorerURL: combinedNetwork.prod.blockExplorerURL,
nativeCurrencySymbol: combinedNetwork.prod.nativeCurrencySymbol}, nativeCurrencySymbol: combinedNetwork.prod.nativeCurrencySymbol},
test: {chainId: combinedNetwork.test.chainId, test: {chainId: combinedNetwork.test.chainId,
@ -139,6 +141,8 @@ QtObject {
chainColor: combinedNetwork.test.chainColor, chainColor: combinedNetwork.test.chainColor,
rpcURL: combinedNetwork.test.rpcURL, rpcURL: combinedNetwork.test.rpcURL,
fallbackURL: combinedNetwork.test.fallbackURL, fallbackURL: combinedNetwork.test.fallbackURL,
originalRpcURL: combinedNetwork.test.originalRpcURL,
originalFallbackURL: combinedNetwork.test.originalFallbackURL,
blockExplorerURL: combinedNetwork.test.blockExplorerURL, blockExplorerURL: combinedNetwork.test.blockExplorerURL,
nativeCurrencySymbol: combinedNetwork.test.nativeCurrencySymbol}, nativeCurrencySymbol: combinedNetwork.test.nativeCurrencySymbol},
layer: combinedNetwork.layer layer: combinedNetwork.layer

View File

@ -131,9 +131,17 @@ ColumnLayout {
id: mainRpcInput id: mainRpcInput
width: parent.width width: parent.width
label: qsTr("Main JSON RPC URL") label: qsTr("Main JSON RPC URL")
text: !!network ? network.rpcURL : "" text: {
if (!network) {
return ""
}
if (network.originalRpcURL == network.rpcURL) {
return network.rpcURL.replace(/(.*\/).*/, '$1')
}
return network.rpcURL
}
onTextChanged: { onTextChanged: {
if(!!text && text !== network.rpcURL) { if(!!text && text !== network.rpcURL.replace(/(.*\/).*/, '$1')) {
d.evaluationStatus = EditNetworkForm.Pending d.evaluationStatus = EditNetworkForm.Pending
Qt.callLater(d.evaluateRpcEndPoint, text); Qt.callLater(d.evaluateRpcEndPoint, text);
} }
@ -154,9 +162,17 @@ ColumnLayout {
id: failoverRpcUrlInput id: failoverRpcUrlInput
Layout.fillWidth: true Layout.fillWidth: true
label: qsTr("Failover JSON RPC URL") label: qsTr("Failover JSON RPC URL")
text: !!network ? network.fallbackURL : "" text: {
if (!network) {
return ""
}
if (network.originalFallbackURL == network.fallbackURL) {
return network.fallbackURL.replace(/(.*\/).*/, '$1')
}
return network.fallbackURL
}
onTextChanged: { onTextChanged: {
if(!!text && text !== network.fallbackURL) { if(!!text && text !== network.fallbackURL.replace(/(.*\/).*/, '$1')) {
d.evaluationStatusFallBackRpc = EditNetworkForm.Pending d.evaluationStatusFallBackRpc = EditNetworkForm.Pending
Qt.callLater(d.evaluateRpcEndPoint, text); Qt.callLater(d.evaluateRpcEndPoint, text);
} }