Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
const baseUrl = chainName => {
let baseUrl;
let chainNameBlockscout = '';
switch (chainName) {
case 'foundation':
chainNameBlockscout = 'mainnet';
baseUrl = `https://blockscout.com/eth/${chainNameBlockscout}`;
break;
case 'kovan':
case 'ropsten':
case 'rinkeby':
chainNameBlockscout = chainName;
baseUrl = `https://blockscout.com/eth/${chainNameBlockscout}`;
break;
default:
console.error(
'Chain name not yet supported. Please notify [email protected]'
);
}
return baseUrl;
};
// Account URL
const ethUrl = (accountAddress, chainName) =>
`${baseUrl(chainName)}/address/${accountAddress}/tokens`;
const tokenUrl = (accountAddress, chainName, tokenAddress) =>
`${baseUrl(
chainName
)}/address/${accountAddress}/tokens/${tokenAddress}/token_transfers`;
const blockscoutAccountUrl = (accountAddress, chainName, tokenAddress) =>
tokenAddress === 'ETH'
? ethUrl(accountAddress, chainName)
: tokenUrl(accountAddress, chainName, tokenAddress);
// Tx URL
const ethTxUrl = (chainName, transactionHash) =>
`${baseUrl(chainName)}/tx/${transactionHash}/internal_transactions`;
const tokenTxUrl = (chainName, transactionHash) =>
`${baseUrl(chainName)}/tx/${transactionHash}/token_transfers`;
const blockscoutTxUrl = (chainName, transactionHash, tokenAddress) =>
tokenAddress === 'ETH'
? ethTxUrl(chainName, transactionHash)
: tokenTxUrl(chainName, transactionHash);
export { blockscoutAccountUrl, blockscoutTxUrl };