Skip to content

Commit

Permalink
feat: blockchain explorer name (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
agazso authored Aug 25, 2023
1 parent cb6d67d commit 13ce67c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions src/lib/adapters/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import {
} from 'ethers'
import abi from '$lib/abis/erc20.json'

interface BlockchainExplorer {
name: string
url: string
}

interface BlockchainNetwork {
name: string
provider: string
explorer: string
explorer?: BlockchainExplorer
nativeToken: Token
tokens?: Token[]
}
Expand All @@ -22,7 +27,6 @@ interface BlockchainNetwork {
const testBlockchain: BlockchainNetwork = {
name: 'Local testnet',
provider: 'http://127.0.0.1:8545',
explorer: '',
nativeToken: {
name: 'Test Ether',
symbol: 'ETH',
Expand All @@ -35,8 +39,11 @@ const testBlockchain: BlockchainNetwork = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const chiadoBlockchain: BlockchainNetwork = {
name: 'Chiado testnet',
explorer: 'https://gnosis-chiado.blockscout.com',
provider: 'https://rpc.chiado.apyos.dev/',
explorer: {
name: 'Blockscout',
url: 'https://gnosis-chiado.blockscout.com',
},
nativeToken: {
name: 'Chiado xDai',
symbol: 'xDai',
Expand All @@ -59,8 +66,11 @@ const chiadoBlockchain: BlockchainNetwork = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const sepoliaBlockchain: BlockchainNetwork = {
name: 'Sepolia testnet',
explorer: 'https://sepolia.etherscan.io/',
provider: 'https://rpc2.sepolia.org/ ',
explorer: {
name: 'Etherscan',
url: 'https://sepolia.etherscan.io/',
},
nativeToken: {
name: 'Sepolia ETH',
symbol: 'SEP',
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/object-detail-item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
id={detailId}
>
<slot />
{#if txHash}
{#if txHash && defaultBlockchainNetwork.explorer}
<div class="view-btn">
<Button
on:click={() =>
window.open(`${defaultBlockchainNetwork.explorer}/tx/${txHash}`, '_blank')}
window.open(`${defaultBlockchainNetwork.explorer?.url}/tx/${txHash}`, '_blank')}
>
<Launch />
View on Etherscan
View on {defaultBlockchainNetwork.explorer.name}
</Button>
</div>
{/if}
Expand Down

0 comments on commit 13ce67c

Please sign in to comment.