fix(@wallet): test etherscan link

fixes #11330
This commit is contained in:
Anthony Laibe 2023-07-03 11:23:26 +02:00 committed by Anthony Laibe
parent fcbc86d882
commit 398cf6455c
3 changed files with 21 additions and 3 deletions

View File

@ -24,6 +24,7 @@ StatusListItem {
property string ens
property string chainShortNames
property bool favourite: false
property bool areTestNetworksEnabled: false
property var saveAddress: function (name, address, favourite, chainShortNames, ens) {}
property var deleteSavedAddress: function (address, ens) {}
@ -163,20 +164,30 @@ StatusListItem {
}
}
StatusMenuSeparator { }
StatusAction {
text: qsTr("View on Etherscan")
objectName: "viewOnEtherscanAction"
assetSettings.name: "external"
onTriggered: {
Global.openLink("https://etherscan.io/address/%1".arg(d.visibleAddress ? d.visibleAddress : root.ens))
var baseUrl = Constants.networkExplorerLinks.etherscan
if (root.areTestNetworksEnabled) {
baseUrl = Constants.networkExplorerLinks.goerliEtherscan
}
Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens))
}
}
StatusAction {
text: qsTr("View on Arbiscan")
objectName: "viewOnArbiscanAction"
assetSettings.name: "external"
onTriggered: {
Global.openLink("https://arbiscan.io/address/%1".arg(d.visibleAddress ? d.visibleAddress : root.ens))
var baseUrl = Constants.networkExplorerLinks.arbiscan
if (root.areTestNetworksEnabled) {
baseUrl = Constants.networkExplorerLinks.goerliArbiscan
}
Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens))
}
}
StatusAction {
@ -184,7 +195,11 @@ StatusListItem {
objectName: "viewOnOptimismExplorerAction"
assetSettings.name: "external"
onTriggered: {
Global.openLink("https://optimistic.etherscan.io/address/%1".arg(d.visibleAddress ? d.visibleAddress : root.ens))
var baseUrl = Constants.networkExplorerLinks.optimistic
if (root.areTestNetworksEnabled) {
baseUrl = Constants.networkExplorerLinks.goerliOptimistic
}
Global.openLink("%1/address/%2".arg(baseUrl).arg(d.visibleAddress ? d.visibleAddress : root.ens))
}
}
StatusMenuSeparator { }

View File

@ -32,6 +32,8 @@ QtObject {
property var flatCollectibles: walletSectionCollectibles.model
property var currentCollectible: walletSectionCurrentCollectible
property var areTestNetworksEnabled: networksModule.areTestNetworksEnabled
property var savedAddresses: SortFilterProxyModel {
sourceModel: walletSectionSavedAddresses.model
filters: [

View File

@ -122,6 +122,7 @@ Item {
favourite: model.favourite
store: RootStore
contactsStore: root.contactsStore
areTestNetworksEnabled: RootStore.areTestNetworksEnabled
onOpenSendModal: root.sendModal.open(recipient);
saveAddress: function(name, address, favourite, chainShortNames, ens) {
_internal.saveAddress(name, address, favourite, chainShortNames, ens)