fix(@desktop/wallet): Fix link out to extherscan from collectibles details view

This commit is contained in:
Khushboo Mehta 2024-03-19 10:49:09 +01:00 committed by Khushboo-dev-cpp
parent 19c283be8b
commit 4f75956ca3
2 changed files with 32 additions and 9 deletions

View File

@ -60,7 +60,7 @@ QtObject {
property CollectiblesStore collectiblesStore: CollectiblesStore {}
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
readonly property bool isGoerliEnabled: networksModule.isGoerliEnabled
readonly property bool isGoerliEnabled: profileSectionModule.walletModule.networksModule.isGoerliEnabled
property var savedAddresses: SortFilterProxyModel {
sourceModel: walletSectionSavedAddresses.model
@ -488,16 +488,39 @@ QtObject {
return root.mainModuleInst.addressWasShown(address)
}
function getExplorerUrl() {
function getExplorerUrl(networkShortName, contractAddress, tokenId) {
let link = Constants.networkExplorerLinks.etherscan
if (root.areTestNetworksEnabled) {
if (root.isGoerliEnabled) {
link = Constants.networkExplorerLinks.goerliEtherscan
} else {
link = Constants.networkExplorerLinks.sepoliaEtherscan
if (networkShortName === Constants.networkShortChainNames.mainnet) {
if (root.areTestNetworksEnabled) {
if (!root.isGoerliEnabled) {
link = Constants.networkExplorerLinks.sepoliaEtherscan
} else {
link = Constants.networkExplorerLinks.goerliEtherscan
}
}
return "%1/nft/%2/%3".arg(link).arg(contractAddress).arg(tokenId)
}
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
link = Constants.networkExplorerLinks.arbiscan
if (root.areTestNetworksEnabled) {
if (!root.isGoerliEnabled) {
link = Constants.networkExplorerLinks.sepoliaArbiscan
} else {
link = Constants.networkExplorerLinks.goerliArbiscan
}
}
return "%1/token/%2?a=%3".arg(link).arg(contractAddress).arg(tokenId)
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
link = Constants.networkExplorerLinks.optimism
if (root.areTestNetworksEnabled) {
if (!root.isGoerliEnabled) {
link = Constants.networkExplorerLinks.sepoliaOptimism
} else {
link = Constants.networkExplorerLinks.goerliOptimism
}
}
return "%1/token/%2?a=%3".arg(link).arg(contractAddress).arg(tokenId)
}
return link
}
function getExplorerNameForNetwork(networkShortName) {

View File

@ -62,7 +62,7 @@ Item {
/* TODO add link out to opensea
https://github.com/status-im/status-desktop/issues/13918 */
}
onOpenCollectibleOnExplorer: Global.openLink("%1/nft/%2/%3".arg(root.walletRootStore.getExplorerUrl()).arg(collectible.contractAddress).arg(collectible.tokenId))
onOpenCollectibleOnExplorer: Global.openLink(root.walletRootStore.getExplorerUrl(collectible.networkShortName, collectible.contractAddress, collectible.tokenId))
}
ColumnLayout {