Module: EvmClient::ExplorerUrlHelper
- Defined in:
- lib/evm_client/explorer_url_helper.rb
Constant Summary collapse
- CHAIN_PREFIX =
{ 17 => "no-explorer-for-devmode.", 42 => "kovan.", 3 => "ropsten.", 4 => "rinkeby.", 5 => "goerli." }
Instance Method Summary collapse
- #explorer_path(suffix, version = EvmClient::Singleton.instance.get_chain) ⇒ Object
- #link_to_address(label, address, **opts) ⇒ Object
- #link_to_tx(label, txid, **opts) ⇒ Object
Instance Method Details
#explorer_path(suffix, version = EvmClient::Singleton.instance.get_chain) ⇒ Object
20 21 22 23 |
# File 'lib/evm_client/explorer_url_helper.rb', line 20 def explorer_path(suffix, version = EvmClient::Singleton.instance.get_chain) prefix = CHAIN_PREFIX.fetch(version, "") "https://#{prefix}etherscan.io/#{suffix}" end |
#link_to_address(label, address, **opts) ⇒ Object
16 17 18 |
# File 'lib/evm_client/explorer_url_helper.rb', line 16 def link_to_address(label, address, **opts) link_to label, explorer_path("address/#{address}"), {target: "_blank"}.merge(opts) end |
#link_to_tx(label, txid, **opts) ⇒ Object
12 13 14 |
# File 'lib/evm_client/explorer_url_helper.rb', line 12 def link_to_tx(label, txid, **opts) link_to label, explorer_path("tx/#{txid}"), {target: "_blank"}.merge(opts) end |