UNPKG

@starknet-react/core

Version:

Starknet React is a collection of React hooks for Starknet.

34 lines (26 loc) 957 B
import type { Chain } from "@starknet-react/chains"; import type { Explorer, ExplorerFactory } from "./explorer"; // Define the StarkscanExplorer class that extends Explorer export class CartridgeExplorer implements Explorer { public name = "Cartridge Explorer"; private link: string; constructor(chain: Chain) { this.link = chain.explorers?.["cartridge"]?.toString() ?? ""; } block(hashOrNumber: { hash?: string; number?: number }): string { return `${this.link}/block/${hashOrNumber.hash ?? hashOrNumber.number}`; } transaction(hash: string): string { return `${this.link}/tx/${hash}`; } contract(address: string): string { return `${this.link}/contract/${address}`; } class(hash: string): string { return `${this.link}/class/${hash}`; } } // Define the starkscan factory function export const cartridge: ExplorerFactory<CartridgeExplorer> = (chain: Chain) => { return new CartridgeExplorer(chain); };