feat(@desktop/wallet): remove address prefixes from wallet account settings

This commit is contained in:
Khushboo Mehta 2024-10-02 19:50:08 +02:00 committed by Khushboo-dev-cpp
parent d6031f8126
commit 60fb566580
10 changed files with 9 additions and 74 deletions

View File

@ -66,10 +66,6 @@ SplitView {
function getAllNetworksChainIds() { function getAllNetworksChainIds() {
return "1:10:42161" return "1:10:42161"
} }
function updateWalletAccountPreferredChains(address, preferredChainIds) {
console.warn("updateWalletAccountPreferredChains :: address ::", address, "preferredChainIds :: ", preferredChainIds)
}
} }
property var keyPairModel: WalletKeyPairModel {} property var keyPairModel: WalletKeyPairModel {}

View File

@ -3,6 +3,7 @@ import QtQuick 2.14
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import AppLayouts.Wallet 1.0 import AppLayouts.Wallet 1.0
@ -12,7 +13,6 @@ StatusListItem {
id: root id: root
property var account property var account
property var getNetworkShortNames: function(chainIds){}
property int totalCount: 0 property int totalCount: 0
property bool nextIconVisible: true property bool nextIconVisible: true
@ -20,7 +20,8 @@ StatusListItem {
objectName: account.name objectName: account.name
title: account.name title: account.name
subTitle: WalletUtils.addressToDisplay(account.address, root.getNetworkShortNames(account.preferredSharingChainIds), true, sensor.containsMouse) subTitle: SQUtils.Utils.elideText(account.address, 6, 4)
statusListItemSubTitle.customColor: sensor.containsMouse ? Theme.palette.directColor1 : Theme.palette.baseColor1
asset.color: !!account.colorId ? Utils.getColorForId(account.colorId): "" asset.color: !!account.colorId ? Utils.getColorForId(account.colorId): ""
asset.emoji: account.emoji asset.emoji: account.emoji
asset.name: !account.emoji ? "filled-account": "" asset.name: !account.emoji ? "filled-account": ""

View File

@ -21,6 +21,7 @@ StatusListItem {
readonly property var timer: Timer {} readonly property var timer: Timer {}
} }
sensor.enabled: isInteractive
statusListItemTitle.customColor: Theme.palette.baseColor1 statusListItemTitle.customColor: Theme.palette.baseColor1
statusListItemTitle.font.pixelSize: 13 statusListItemTitle.font.pixelSize: 13
statusListItemTitle.lineHeightMode: Text.FixedHeight statusListItemTitle.lineHeightMode: Text.FixedHeight

View File

@ -16,7 +16,6 @@ Rectangle {
property var keyPair property var keyPair
property bool hasPairedDevices property bool hasPairedDevices
property var getNetworkShortNames: function(chainIds){}
property string userProfilePublicKey property string userProfilePublicKey
signal goToAccountView(var account) signal goToAccountView(var account)
@ -112,7 +111,6 @@ Rectangle {
width: ListView.view.width width: ListView.view.width
account: model.account account: model.account
totalCount: ListView.view.count totalCount: ListView.view.count
getNetworkShortNames: root.getNetworkShortNames
onGoToAccountView: root.goToAccountView(model.account) onGoToAccountView: root.goToAccountView(model.account)
RowLayout { RowLayout {

View File

@ -19,7 +19,6 @@ StatusDialog {
property string name property string name
property var relatedAccounts property var relatedAccounts
property var getNetworkShortNames: function(chainIds){}
signal confirmClicked() signal confirmClicked()
@ -68,7 +67,6 @@ StatusDialog {
id: delegate id: delegate
width: parent.width width: parent.width
account : model.account account : model.account
getNetworkShortNames: root.getNetworkShortNames
color: Theme.palette.transparent color: Theme.palette.transparent
nextIconVisible: false nextIconVisible: false
components: StatusBaseText { components: StatusBaseText {

View File

@ -26,11 +26,9 @@ StatusMenu {
name: "", name: "",
emoji: "", emoji: "",
colorId: "", colorId: "",
preferredSharingChainIds: ""
}) })
property bool areTestNetworksEnabled: false property bool areTestNetworksEnabled: false
property bool isGoerliEnabled: false property bool isGoerliEnabled: false
property var preferredSharedNetworkNamesArray
signal copyToClipboard(string address) signal copyToClipboard(string address)
@ -42,7 +40,6 @@ StatusMenu {
StatusAction { StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.mainnet) text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.mainnet)
enabled: root.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.mainnet)
icon.name: "link" icon.name: "link"
onTriggered: { onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "") let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
@ -52,7 +49,6 @@ StatusMenu {
StatusAction { StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.arbitrum) text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.arbitrum)
enabled: root.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.arbitrum)
icon.name: "link" icon.name: "link"
onTriggered: { onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "") let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
@ -62,7 +58,6 @@ StatusMenu {
StatusAction { StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.optimism) text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.optimism)
enabled: root.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.optimism)
icon.name: "link" icon.name: "link"
onTriggered: { onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "") let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
@ -89,8 +84,7 @@ StatusMenu {
name: root.selectedAccount.name?? "", name: root.selectedAccount.name?? "",
address: root.selectedAccount.address?? "", address: root.selectedAccount.address?? "",
emoji: root.selectedAccount.emoji?? "", emoji: root.selectedAccount.emoji?? "",
colorId: root.selectedAccount.colorId?? "", colorId: root.selectedAccount.colorId?? ""
preferredSharingChainIds: root.selectedAccount.preferredSharingChainIds?? ""
}) })
} }
} }

View File

@ -163,15 +163,6 @@ QtObject {
networksModuleInst.updateNetworkEndPointValues(chainId, testNetwork, newMainRpcInput, newFailoverRpcUrl, revertToDefault) networksModuleInst.updateNetworkEndPointValues(chainId, testNetwork, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
} }
function updateWalletAccountPreferredChains(address, preferredChainIds) {
if(areTestNetworksEnabled) {
accountsModule.updateWalletAccountTestPreferredChains(address, preferredChainIds)
}
else {
accountsModule.updateWalletAccountProdPreferredChains(address, preferredChainIds)
}
}
function getNetworkShortNames(chainIds) { function getNetworkShortNames(chainIds) {
return networksModuleInst.getNetworkShortNames(chainIds) return networksModuleInst.getNetworkShortNames(chainIds)
} }

View File

@ -447,7 +447,6 @@ SettingsContentBase {
sourceComponent: RemoveKeypairPopup { sourceComponent: RemoveKeypairPopup {
name: removeKeypairPopup.name name: removeKeypairPopup.name
relatedAccounts: removeKeypairPopup.accounts relatedAccounts: removeKeypairPopup.accounts
getNetworkShortNames: function(chainIds) {return root.walletStore.getNetworkShortNames(chainIds)}
onClosed: removeKeypairPopup.active = false onClosed: removeKeypairPopup.active = false
onConfirmClicked: { onConfirmClicked: {
root.walletStore.deleteKeypair(removeKeypairPopup.keyUid) root.walletStore.deleteKeypair(removeKeypairPopup.keyUid)

View File

@ -44,9 +44,6 @@ ColumnLayout {
readonly property bool watchOnlyAccount: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.watchOnly: false readonly property bool watchOnlyAccount: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.watchOnly: false
readonly property bool privateKeyAccount: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.privateKeyImport: false readonly property bool privateKeyAccount: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.privateKeyImport: false
readonly property bool seedImport: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.seedImport: false readonly property bool seedImport: !!root.keyPair? root.keyPair.pairType === Constants.keypair.type.seedImport: false
readonly property string preferredSharingNetworks: !!root.account? root.account.preferredSharingChainIds: ""
property var preferredSharingNetworksArray: preferredSharingNetworks.split(":").filter(Boolean).map(Number)
property string preferredSharingNetworkShortNames: walletStore.getNetworkShortNames(preferredSharingNetworks)
} }
spacing: 0 spacing: 0
@ -130,10 +127,7 @@ ColumnLayout {
isInteractive: true isInteractive: true
moreButtonEnabled: true moreButtonEnabled: true
title: qsTr("Address") title: qsTr("Address")
subTitle: { subTitle: !!root.account && root.account.address ? root.account.address: ""
let address = !!root.account && root.account.address ? root.account.address: ""
return WalletUtils.colorizedChainPrefix(d.preferredSharingNetworkShortNames) + address
}
onButtonClicked: addressMenu.openMenu(this) onButtonClicked: addressMenu.openMenu(this)
} }
Separator { Separator {
@ -219,6 +213,7 @@ ColumnLayout {
} }
Separator { Separator {
visible: d.watchOnlyAccount
Layout.topMargin: 40 Layout.topMargin: 40
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 1 Layout.preferredHeight: 1
@ -246,43 +241,6 @@ ColumnLayout {
color: Theme.palette.baseColor2 color: Theme.palette.baseColor2
} }
StatusListItem {
objectName: "PreferredNetworks_ListItem"
Layout.fillWidth: true
Layout.topMargin: Style.current.halfPadding
title: qsTr("Preferred networks when sharing this address")
color: Theme.palette.transparent
components: [
NetworkFilter {
flatNetworks: root.walletStore.filteredFlatModel
multiSelection: true
selection: d.preferredSharingNetworksArray
property string initialSelection
onSelectionChanged: {
if (selection !== d.preferredSharingNetworksArray) {
d.preferredSharingNetworksArray = selection
}
}
control.popup.onOpened: initialSelection = JSON.stringify(selection)
control.popup.onClosed: {
if (!!root.account && initialSelection !== JSON.stringify(selection)) {
root.walletStore.updateWalletAccountPreferredChains(root.account.address, d.preferredSharingNetworksArray.join(":"))
}
}
}
]
}
Separator {
Layout.fillWidth: true
Layout.preferredHeight: 1
color: Theme.palette.baseColor2
}
StatusButton { StatusButton {
Layout.topMargin: 20 Layout.topMargin: 20
Layout.fillWidth: true Layout.fillWidth: true
@ -309,7 +267,8 @@ ColumnLayout {
accountName: !!root.account ? root.account.name : "" accountName: !!root.account ? root.account.name : ""
accountAddress: !!root.account ? root.account.address : "" accountAddress: !!root.account ? root.account.address : ""
accountDerivationPath: !!root.account ? root.account.path : "" accountDerivationPath: !!root.account ? root.account.path : ""
preferredSharingNetworkShortNames: d.preferredSharingNetworkShortNames // TODO: remove in when RemoveAccountConfirmationPopup.qml removes preferred networks
preferredSharingNetworkShortNames: ""
emoji: !!root.account ? root.account.emoji : "" emoji: !!root.account ? root.account.emoji : ""
color: !!root.account ? Utils.getColorForId(root.account.colorId) : "" color: !!root.account ? Utils.getColorForId(root.account.colorId) : ""
@ -337,7 +296,6 @@ ColumnLayout {
selectedAccount: root.account selectedAccount: root.account
areTestNetworksEnabled: root.walletStore.areTestNetworksEnabled areTestNetworksEnabled: root.walletStore.areTestNetworksEnabled
isGoerliEnabled: root.walletStore.isGoerliEnabled isGoerliEnabled: root.walletStore.isGoerliEnabled
preferredSharedNetworkNamesArray: d.preferredSharingNetworkShortNames.split(":").filter(Boolean)
onCopyToClipboard: ClipboardUtils.setText(address) onCopyToClipboard: ClipboardUtils.setText(address)
} }

View File

@ -285,7 +285,6 @@ Column {
width: parent.width width: parent.width
keyPair: model.keyPair keyPair: model.keyPair
hasPairedDevices: root.walletStore.walletModule.hasPairedDevices hasPairedDevices: root.walletStore.walletModule.hasPairedDevices
getNetworkShortNames: walletStore.getNetworkShortNames
userProfilePublicKey: walletStore.userProfilePublicKey userProfilePublicKey: walletStore.userProfilePublicKey
onGoToAccountView: root.goToAccountView(account) onGoToAccountView: root.goToAccountView(account)
onRunRenameKeypairFlow: root.runRenameKeypairFlow(model) onRunRenameKeypairFlow: root.runRenameKeypairFlow(model)