Fix explorer url for POA network on confirmed transaction
This commit is contained in:
Victor Baranov 2018-08-02 12:45:13 +03:00 committed by GitHub
commit 61a14d6065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -2,6 +2,7 @@
## Current Master
- [#54](https://github.com/poanetwork/metamask-extension/pull/54): Fix explorer url for POA network on confirmed transaction.
- [#50](https://github.com/poanetwork/metamask-extension/pull/50): Update sentry links.
- [#45](https://github.com/poanetwork/metamask-extension/pull/45): Automate release publish.

View File

@ -56,11 +56,11 @@ class ExtensionPlatform {
this._subscribeToNotificationClicked()
const url = explorerLink(txMeta.hash, parseInt(txMeta.metamaskNetworkId))
const { url, explorerName } = this._getExplorer(txMeta.hash, parseInt(txMeta.metamaskNetworkId))
const nonce = parseInt(txMeta.txParams.nonce, 16)
const title = 'Confirmed transaction'
const message = `Transaction ${nonce} confirmed! View on EtherScan`
const message = `Transaction ${nonce} confirmed! View on ${explorerName}`
this._showNotification(title, message, url)
}
@ -90,10 +90,30 @@ class ExtensionPlatform {
}
_viewOnEtherScan (txId) {
if (txId.startsWith('http://')) {
if (txId.startsWith('http://') || txId.startsWith('https://')) {
global.metamaskController.platform.openWindow({ url: txId })
}
}
_getExplorer (hash, networkId) {
if (networkId === 99) {
return {
explorerName: 'POA explorer',
url: `https://poaexplorer.com/txid/search/${hash}`,
}
} else if (networkId === 77) {
return {
explorerName: 'POA explorer',
url: `https://sokol.poaexplorer.com/txid/search/${hash}`,
}
} else {
return {
explorerName: 'Etherscan',
url: explorerLink(hash, networkId),
}
}
}
}
module.exports = ExtensionPlatform