npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yoroi/explorers

v1.0.2

Published

The Explorers package of Yoroi SDK

Downloads

55

Readme

@yoroi/explorers

Overview

The @yoroi/explorers is a TypeScript package designed to manage and interact with various blockchain explorers supported by the Yoroi Wallet. The package provides a consistent interface for generating URLs for different blockchain networks and explorers.

Installation

To install the package, you can use npm or yarn:

npm install @yoroi/explorers

or

yarn add @yoroi/explorers

Usage

To use @yoroi/explorers, you can import the necessary types and functions to generate URLs for tokens, addresses, transactions, pools, and stake keys.

Example

import {Chain, Explorers} from '@yoroi/types'
import {explorerManager} from '@yoroi/explorers'

// Build the manager
const mainnetExplorer = explorerManager[Chain.Network.Mainnet]

// Generate URLs using CardanoScan explorer
const tokenUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].token('fingerprint')
const addressUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].address('address')
const txUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].tx('txHash')
const poolUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].pool('poolId')
const stakeUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress')

console.log(tokenUrl) // Output: https://cardanoscan.io/token/fingerprint
console.log(addressUrl) // Output: https://cardanoscan.io/address/address
console.log(txUrl) // Output: https://cardanoscan.io/transaction/txHash
console.log(poolUrl) // Output: https://cardanoscan.io/pool/poolId
console.log(stakeUrl) // Output: https://cardanoscan.io/stakeKey/stakeAddress

This example shows how to use the explorerManager object to generate URLs for different entities on the Mainnet using the CardanoScan explorer.

About Supported Networks and Explorers

The following networks and explorers are supported:

Networks:

  1. Mainnet: The live network for Cardano.
  2. Preprod: The pre-production network for testing.
  3. Sancho: The temporary Conway test network for governance.
  4. Preview: A preview network for new features.

Explorers:

  1. CardanoScan: A popular Cardano blockchain explorer.

    1. Twitter X
    2. Discord Discord
    3. Explorer
  2. CExplorer: Another Cardano blockchain explorer.

    1. Explorer

URL Generation

For each network and explorer, the following URL generation methods are available:

token(fingerprint: string)

address(address: string)

tx(txHash: string)

pool(poolId: string)

stake(stakeAddress: string)

Adding a New Explorer

If you are a developer working on a new Cardano explorer and want to add support for it in Yoroi, you can do so by following these steps:

  1. Fork the Repository Start by forking the @yoroi/explorers repository on GitHub.

  2. Add Your Explorer URLs In the codebase, navigate to the explorer-manager.ts file. Add your explorer under the appropriate network with the URL generation methods (token, address, tx, pool, stake, etc).

    For example:

    [Chain.Network.Mainnet]: {
       [Explorers.Explorer.YourExplorerName]: {
         token: (fingerprint: string) => `https://yourexplorer.io/token/${fingerprint}`,
         address: (address: string) => `https://yourexplorer.io/address/${address}`,
         tx: (txHash: string) => `https://yourexplorer.io/transaction/${txHash}`,
         pool: (poolId: string) => `https://yourexplorer.io/pool/${poolId}`,
         stake: (stakeAddress: string) => `https://yourexplorer.io/stake/${stakeAddress}`,
      },
    }, 
  3. Test Your Implementation Write unit tests to ensure that the URLs generated for your explorer are correct. You can follow the existing test patterns in the explorerManager test suite, 100% coverage is expected.

    Running Tests

    yarn test

    This will run the unit tests to ensure that everything is working as expected.

  4. Submit a Pull Request (PR) Once you've implemented and tested your explorer integration, submit a PR to the repository. The Yoroi development team will review your submission.

Contributing

We welcome contributions from the community! If you find a bug or have a feature request, please open an issue or submit a pull request.