feat(@desktop/wallet): Wallet settings - Notification after each action
fixes #11719
This commit is contained in:
parent
a06cd4b8a5
commit
11820d0400
|
@ -394,6 +394,14 @@ proc connectForNotificationsOnly[T](self: Module[T]) =
|
||||||
let args = KeypairArgs(e)
|
let args = KeypairArgs(e)
|
||||||
self.view.showToastKeypairRenamed(args.oldKeypairName, args.keypair.name)
|
self.view.showToastKeypairRenamed(args.oldKeypairName, args.keypair.name)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
|
||||||
|
let args = NetworkEndpointUpdatedArgs(e)
|
||||||
|
self.view.showNetworkEndpointUpdated(args.networkName, args.isTest)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED) do(e: Args):
|
||||||
|
let args = SettingsBoolValueArgs(e)
|
||||||
|
self.view.showIncludeWatchOnlyAccountUpdated(args.value)
|
||||||
|
|
||||||
method load*[T](
|
method load*[T](
|
||||||
self: Module[T],
|
self: Module[T],
|
||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
|
|
|
@ -75,11 +75,13 @@ method createKeypairItems*(self: Module, walletAccounts: seq[WalletAccountDto],
|
||||||
var keyPairItems = keypairs.buildKeyPairsList(self.controller.getKeypairs(), excludeAlreadyMigratedPairs = false,
|
var keyPairItems = keypairs.buildKeyPairsList(self.controller.getKeypairs(), excludeAlreadyMigratedPairs = false,
|
||||||
excludePrivateKeyKeypairs = false, self.controller.areTestNetworksEnabled())
|
excludePrivateKeyKeypairs = false, self.controller.areTestNetworksEnabled())
|
||||||
|
|
||||||
var item = newKeyPairItem()
|
var watchOnlyAccounts = walletAccounts.filter(a => a.walletType == WalletTypeWatch).map(x => self.convertWalletAccountDtoToKeyPairAccountItem(x))
|
||||||
item.setIcon("show")
|
if watchOnlyAccounts.len > 0:
|
||||||
item.setPairType(KeyPairType.WatchOnly.int)
|
var item = newKeyPairItem()
|
||||||
item.setAccounts(walletAccounts.filter(a => a.walletType == WalletTypeWatch).map(x => self.convertWalletAccountDtoToKeyPairAccountItem(x)))
|
item.setIcon("show")
|
||||||
keyPairItems.add(item)
|
item.setPairType(KeyPairType.WatchOnly.int)
|
||||||
|
item.setAccounts(watchOnlyAccounts)
|
||||||
|
keyPairItems.add(item)
|
||||||
|
|
||||||
for address, tokens in accountsTokens.pairs:
|
for address, tokens in accountsTokens.pairs:
|
||||||
let balance = currencyAmountToItem(tokens.map(t => t.getCurrencyBalance(enabledChainIds, currency)).foldl(a + b, 0.0),currencyFormat)
|
let balance = currencyAmountToItem(tokens.map(t => t.getCurrencyBalance(enabledChainIds, currency)).foldl(a + b, 0.0),currencyFormat)
|
||||||
|
|
|
@ -38,6 +38,9 @@ proc init*(self: Controller) =
|
||||||
let args = ChainIdForUrlArgs(e)
|
let args = ChainIdForUrlArgs(e)
|
||||||
self.delegate.chainIdFetchedForUrl(args.url, args.chainId, args.success)
|
self.delegate.chainIdFetchedForUrl(args.url, args.chainId, args.success)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_NETWORK_ENDPOINT_UPDATED) do(e: Args):
|
||||||
|
self.delegate.refreshNetworks()
|
||||||
|
|
||||||
proc getNetworks*(self: Controller): seq[CombinedNetworkDto] =
|
proc getNetworks*(self: Controller): seq[CombinedNetworkDto] =
|
||||||
return self.networkService.getCombinedNetworks()
|
return self.networkService.getCombinedNetworks()
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ QtObject:
|
||||||
proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} =
|
proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} =
|
||||||
return self.combinedNetworks.getNetworkShortNames(preferredNetworks, self.areTestNetworksEnabled)
|
return self.combinedNetworks.getNetworkShortNames(preferredNetworks, self.areTestNetworksEnabled)
|
||||||
|
|
||||||
proc updateNetworkEndPointValues*(self: View, chainId: int, newMainRpcInput, newFailoverRpcUrl: string) =
|
proc updateNetworkEndPointValues*(self: View, chainId: int, newMainRpcInput: string, newFailoverRpcUrl: string) {.slot.} =
|
||||||
self.delegate.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
self.delegate.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
||||||
|
|
||||||
proc fetchChainIdForUrl*(self: View, url: string) {.slot.} =
|
proc fetchChainIdForUrl*(self: View, url: string) {.slot.} =
|
||||||
|
|
|
@ -274,3 +274,5 @@ QtObject:
|
||||||
## Signals for in app (ephemeral) notifications
|
## Signals for in app (ephemeral) notifications
|
||||||
proc showToastAccountAdded*(self: View, name: string) {.signal.}
|
proc showToastAccountAdded*(self: View, name: string) {.signal.}
|
||||||
proc showToastKeypairRenamed*(self: View, oldName: string, newName: string) {.signal.}
|
proc showToastKeypairRenamed*(self: View, oldName: string, newName: string) {.signal.}
|
||||||
|
proc showNetworkEndpointUpdated*(self: View, name: string, isTest: bool) {.signal.}
|
||||||
|
proc showIncludeWatchOnlyAccountUpdated*(self: View, includeWatchOnly: bool) {.signal.}
|
||||||
|
|
|
@ -11,6 +11,12 @@ export dto, types
|
||||||
logScope:
|
logScope:
|
||||||
topics = "network-service"
|
topics = "network-service"
|
||||||
|
|
||||||
|
const SIGNAL_NETWORK_ENDPOINT_UPDATED* = "networkEndPointUpdated"
|
||||||
|
|
||||||
|
type NetworkEndpointUpdatedArgs* = ref object of Args
|
||||||
|
isTest*: bool
|
||||||
|
networkName*: string
|
||||||
|
|
||||||
type
|
type
|
||||||
Service* = ref object of RootObj
|
Service* = ref object of RootObj
|
||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
|
@ -57,8 +63,8 @@ proc getNetworks*(self: Service): seq[NetworkDto] =
|
||||||
else:
|
else:
|
||||||
result.add(network.prod)
|
result.add(network.prod)
|
||||||
|
|
||||||
proc upsertNetwork*(self: Service, network: NetworkDto) =
|
proc upsertNetwork*(self: Service, network: NetworkDto): bool =
|
||||||
discard backend.addEthereumChain(backend.Network(
|
let response = backend.addEthereumChain(backend.Network(
|
||||||
chainId: network.chainId,
|
chainId: network.chainId,
|
||||||
nativeCurrencyDecimals: network.nativeCurrencyDecimals,
|
nativeCurrencyDecimals: network.nativeCurrencyDecimals,
|
||||||
layer: network.layer,
|
layer: network.layer,
|
||||||
|
@ -76,6 +82,7 @@ proc upsertNetwork*(self: Service, network: NetworkDto) =
|
||||||
relatedChainID: network.relatedChainID,
|
relatedChainID: network.relatedChainID,
|
||||||
))
|
))
|
||||||
self.dirty.store(true)
|
self.dirty.store(true)
|
||||||
|
return response.error == nil
|
||||||
|
|
||||||
proc deleteNetwork*(self: Service, network: NetworkDto) =
|
proc deleteNetwork*(self: Service, network: NetworkDto) =
|
||||||
discard backend.deleteEthereumChain(network.chainId)
|
discard backend.deleteEthereumChain(network.chainId)
|
||||||
|
@ -89,6 +96,13 @@ proc getNetwork*(self: Service, chainId: int): NetworkDto =
|
||||||
if chainId == net.chainId:
|
if chainId == net.chainId:
|
||||||
return net
|
return net
|
||||||
|
|
||||||
|
proc getNetworkByChainId*(self: Service, chainId: int): NetworkDto =
|
||||||
|
for network in self.fetchNetworks():
|
||||||
|
if chainId == network.prod.chainId:
|
||||||
|
return network.prod
|
||||||
|
elif chainId == network.test.chainId:
|
||||||
|
return network.test
|
||||||
|
|
||||||
proc getNetwork*(self: Service, networkType: NetworkType): NetworkDto =
|
proc getNetwork*(self: Service, networkType: NetworkType): NetworkDto =
|
||||||
let testNetworksEnabled = self.settingsService.areTestNetworksEnabled()
|
let testNetworksEnabled = self.settingsService.areTestNetworksEnabled()
|
||||||
for network in self.fetchNetworks():
|
for network in self.fetchNetworks():
|
||||||
|
@ -108,7 +122,7 @@ proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
||||||
continue
|
continue
|
||||||
|
|
||||||
network.enabled = enabled
|
network.enabled = enabled
|
||||||
self.upsertNetwork(network)
|
discard self.upsertNetwork(network)
|
||||||
|
|
||||||
proc getChainIdForEns*(self: Service): int =
|
proc getChainIdForEns*(self: Service): int =
|
||||||
if self.settingsService.areTestNetworksEnabled():
|
if self.settingsService.areTestNetworksEnabled():
|
||||||
|
@ -141,7 +155,7 @@ proc getNetworkForCollectibles*(self: Service): NetworkDto =
|
||||||
return self.getNetwork(Mainnet)
|
return self.getNetwork(Mainnet)
|
||||||
|
|
||||||
proc updateNetworkEndPointValues*(self: Service, chainId: int, newMainRpcInput, newFailoverRpcUrl: string) =
|
proc updateNetworkEndPointValues*(self: Service, chainId: int, newMainRpcInput, newFailoverRpcUrl: string) =
|
||||||
let network = self.getNetwork(chainId)
|
let network = self.getNetworkByChainId(chainId)
|
||||||
|
|
||||||
if network.rpcURL == newMainRpcInput and network.fallbackURL == newFailoverRpcUrl:
|
if network.rpcURL == newMainRpcInput and network.fallbackURL == newFailoverRpcUrl:
|
||||||
return
|
return
|
||||||
|
@ -152,5 +166,5 @@ proc updateNetworkEndPointValues*(self: Service, chainId: int, newMainRpcInput,
|
||||||
if network.fallbackURL != newFailoverRpcUrl:
|
if network.fallbackURL != newFailoverRpcUrl:
|
||||||
network.fallbackURL = newFailoverRpcUrl
|
network.fallbackURL = newFailoverRpcUrl
|
||||||
|
|
||||||
self.upsertNetwork(network)
|
if self.upsertNetwork(network):
|
||||||
|
self.events.emit(SIGNAL_NETWORK_ENDPOINT_UPDATED, NetworkEndpointUpdatedArgs(isTest: network.isTest, networkName: network.chainName))
|
||||||
|
|
|
@ -47,6 +47,9 @@ type
|
||||||
SettingProfilePictureArgs* = ref object of Args
|
SettingProfilePictureArgs* = ref object of Args
|
||||||
value*: int
|
value*: int
|
||||||
|
|
||||||
|
SettingsBoolValueArgs* = ref object of Args
|
||||||
|
value*: bool
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type Service* = ref object of QObject
|
type Service* = ref object of QObject
|
||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
|
@ -974,4 +977,4 @@ QtObject:
|
||||||
let newValue = not self.settings.includeWatchOnlyAccount
|
let newValue = not self.settings.includeWatchOnlyAccount
|
||||||
if(self.saveSetting(INCLUDE_WATCH_ONLY_ACCOUNT, newValue)):
|
if(self.saveSetting(INCLUDE_WATCH_ONLY_ACCOUNT, newValue)):
|
||||||
self.settings.includeWatchOnlyAccount = newValue
|
self.settings.includeWatchOnlyAccount = newValue
|
||||||
self.events.emit(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED, Args())
|
self.events.emit(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED, SettingsBoolValueArgs(value: newValue))
|
||||||
|
|
|
@ -108,4 +108,30 @@ QtObject {
|
||||||
function copyToClipboard(textToCopy) {
|
function copyToClipboard(textToCopy) {
|
||||||
globalUtils.copyToClipboard(textToCopy)
|
globalUtils.copyToClipboard(textToCopy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNetworkData(combinedNetwork) {
|
||||||
|
return {
|
||||||
|
prod: {chainId: combinedNetwork.prod.chainId,
|
||||||
|
layer: combinedNetwork.prod.layer,
|
||||||
|
chainName: combinedNetwork.prod.chainName,
|
||||||
|
iconUrl: combinedNetwork.prod.iconUrl,
|
||||||
|
shortName: combinedNetwork.prod.shortName,
|
||||||
|
chainColor: combinedNetwork.prod.chainColor,
|
||||||
|
rpcURL: combinedNetwork.prod.rpcURL,
|
||||||
|
fallbackURL: combinedNetwork.prod.fallbackURL,
|
||||||
|
blockExplorerURL: combinedNetwork.prod.blockExplorerURL,
|
||||||
|
nativeCurrencySymbol: combinedNetwork.prod.nativeCurrencySymbol},
|
||||||
|
test: {chainId: combinedNetwork.test.chainId,
|
||||||
|
layer: combinedNetwork.test.layer,
|
||||||
|
chainName: combinedNetwork.test.chainName,
|
||||||
|
iconUrl: combinedNetwork.test.iconUrl,
|
||||||
|
shortName: combinedNetwork.test.shortName,
|
||||||
|
chainColor: combinedNetwork.test.chainColor,
|
||||||
|
rpcURL: combinedNetwork.test.rpcURL,
|
||||||
|
fallbackURL: combinedNetwork.test.fallbackURL,
|
||||||
|
blockExplorerURL: combinedNetwork.test.blockExplorerURL,
|
||||||
|
nativeCurrencySymbol: combinedNetwork.test.nativeCurrencySymbol},
|
||||||
|
layer: combinedNetwork.layer
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,10 @@ SettingsContentBase {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
networksModule: root.walletStore.networksModule
|
networksModule: root.walletStore.networksModule
|
||||||
onEvaluateRpcEndPoint: root.walletStore.evaluateRpcEndPoint(url)
|
onEvaluateRpcEndPoint: root.walletStore.evaluateRpcEndPoint(url)
|
||||||
onUpdateNetworkValues: root.walletStore.updateNetworkValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
onUpdateNetworkValues: {
|
||||||
|
root.walletStore.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
||||||
|
stackContainer.currentIndex = networksViewIndex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountOrderView {
|
AccountOrderView {
|
||||||
|
|
|
@ -28,22 +28,25 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StackLayout {
|
Loader {
|
||||||
id: stackLayout
|
|
||||||
Layout.preferredHeight: currentIndex === 0 ? editLiveNetwork.height: editTestNetwork.height
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
currentIndex: editPreviwTabBar.currentIndex
|
active: root.visible
|
||||||
|
sourceComponent: editPreviwTabBar.currentIndex === 0 ? editLiveNetwork: editTestNetwork
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: editLiveNetwork
|
||||||
EditNetworkForm {
|
EditNetworkForm {
|
||||||
id: editLiveNetwork
|
|
||||||
network: !!root.combinedNetwork ? root.combinedNetwork.prod: null
|
network: !!root.combinedNetwork ? root.combinedNetwork.prod: null
|
||||||
networksModule: root.networksModule
|
networksModule: root.networksModule
|
||||||
onEvaluateRpcEndPoint: root.evaluateRpcEndPoint(url)
|
onEvaluateRpcEndPoint: root.evaluateRpcEndPoint(url)
|
||||||
onUpdateNetworkValues: root.updateNetworkValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
onUpdateNetworkValues: root.updateNetworkValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: editTestNetwork
|
||||||
EditNetworkForm {
|
EditNetworkForm {
|
||||||
id: editTestNetwork
|
|
||||||
network: !!root.combinedNetwork ? root.combinedNetwork.test: null
|
network: !!root.combinedNetwork ? root.combinedNetwork.test: null
|
||||||
networksModule: root.networksModule
|
networksModule: root.networksModule
|
||||||
onEvaluateRpcEndPoint: root.evaluateRpcEndPoint(url)
|
onEvaluateRpcEndPoint: root.evaluateRpcEndPoint(url)
|
||||||
|
|
|
@ -42,7 +42,7 @@ Item {
|
||||||
delegate: WalletNetworkDelegate {
|
delegate: WalletNetworkDelegate {
|
||||||
network: areTestNetworksEnabled ? model.test: model.prod
|
network: areTestNetworksEnabled ? model.test: model.prod
|
||||||
areTestNetworksEnabled: walletStore.areTestNetworksEnabled
|
areTestNetworksEnabled: walletStore.areTestNetworksEnabled
|
||||||
onClicked: editNetwork(model)
|
onClicked: editNetwork(walletStore.getNetworkData(model))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ Item {
|
||||||
delegate: WalletNetworkDelegate {
|
delegate: WalletNetworkDelegate {
|
||||||
network: areTestNetworksEnabled ? model.test: model.prod
|
network: areTestNetworksEnabled ? model.test: model.prod
|
||||||
areTestNetworksEnabled: walletStore.areTestNetworksEnabled
|
areTestNetworksEnabled: walletStore.areTestNetworksEnabled
|
||||||
onClicked: editNetwork(model)
|
onClicked: editNetwork(walletStore.getNetworkData(model))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ Item {
|
||||||
Global.displayToastMessage(
|
Global.displayToastMessage(
|
||||||
qsTr("\"%1\" successfuly added").arg(name),
|
qsTr("\"%1\" successfuly added").arg(name),
|
||||||
"",
|
"",
|
||||||
"check-circle",
|
"checkmark-circle",
|
||||||
false,
|
false,
|
||||||
Constants.ephemeralNotificationType.success,
|
Constants.ephemeralNotificationType.success,
|
||||||
""
|
""
|
||||||
|
@ -110,12 +110,33 @@ Item {
|
||||||
Global.displayToastMessage(
|
Global.displayToastMessage(
|
||||||
qsTr("You successfully renamed your keypair\nfrom \"%1\" to \"%2\"").arg(oldName).arg(newName),
|
qsTr("You successfully renamed your keypair\nfrom \"%1\" to \"%2\"").arg(oldName).arg(newName),
|
||||||
"",
|
"",
|
||||||
"check-circle",
|
"checkmark-circle",
|
||||||
false,
|
false,
|
||||||
Constants.ephemeralNotificationType.success,
|
Constants.ephemeralNotificationType.success,
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onShowNetworkEndpointUpdated(name: string, isTest: bool) {
|
||||||
|
Global.displayToastMessage(
|
||||||
|
isTest ? qsTr("Test network settings for %1 updated").arg(name): qsTr("Live network settings for %1 updated").arg(name),
|
||||||
|
"",
|
||||||
|
"checkmark-circle",
|
||||||
|
false,
|
||||||
|
Constants.ephemeralNotificationType.success,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onShowIncludeWatchOnlyAccountUpdated(includeWatchOnly: bool) {
|
||||||
|
Global.displayToastMessage(
|
||||||
|
includeWatchOnly ? qsTr("Your wallet’s total balance will now include balances of watched addresses") : qsTr("Your wallet’s total balance will not include balances of watched addresses") ,
|
||||||
|
"",
|
||||||
|
"checkmark-circle",
|
||||||
|
false,
|
||||||
|
Constants.ephemeralNotificationType.success,
|
||||||
|
"")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f510eae70f00c6daab8eed7395b7fbf4332755e
|
Subproject commit a63e417f9f6c779300f35b51998770742f5e363f
|
Loading…
Reference in New Issue