-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use etherscan-link customBlockExplorer methods with customNetwork usa…
…ge tracking (#11017) * use etherscan-link customBlockExplorer methods with customNetwork usage tracking * consolidate blockexplorer events, add domain to metametrics event * lint fix
- Loading branch information
Showing
18 changed files
with
247 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,6 @@ | ||
import { | ||
createExplorerLink, | ||
createExplorerLinkForChain, | ||
} from '@metamask/etherscan-link'; | ||
|
||
export function transactionMatchesNetwork(transaction, chainId, networkId) { | ||
if (typeof transaction.chainId !== 'undefined') { | ||
return transaction.chainId === chainId; | ||
} | ||
return transaction.metamaskNetworkId === networkId; | ||
} | ||
|
||
/** | ||
* build the etherscan link for a transaction by either chainId, if available | ||
* or metamaskNetworkId as a fallback. If rpcPrefs is provided will build the | ||
* url for the provided blockExplorerUrl. | ||
* | ||
* @param {Object} transaction - a transaction object from state | ||
* @param {string} [transaction.metamaskNetworkId] - network id tx occurred on | ||
* @param {string} [transaction.chainId] - chain id tx occurred on | ||
* @param {string} [transaction.hash] - hash of the transaction | ||
* @param {Object} [rpcPrefs] - the rpc preferences for the current RPC network | ||
* @param {string} [rpcPrefs.blockExplorerUrl] - the block explorer url for RPC | ||
* networks | ||
* @returns {string} | ||
*/ | ||
export function getBlockExplorerUrlForTx(transaction, rpcPrefs = {}) { | ||
if (rpcPrefs.blockExplorerUrl) { | ||
return `${rpcPrefs.blockExplorerUrl.replace(/\/+$/u, '')}/tx/${ | ||
transaction.hash | ||
}`; | ||
} | ||
if (transaction.chainId) { | ||
return createExplorerLinkForChain(transaction.hash, transaction.chainId); | ||
} | ||
return createExplorerLink(transaction.hash, transaction.metamaskNetworkId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.