near-ca
Version:
An SDK for controlling Ethereum Accounts from a Near Account.
81 lines (80 loc) • 2.59 kB
TypeScript
import { PublicClient } from "viem";
/** Interface defining the required fields for a network configuration */
export interface NetworkFields {
/** Display name of the network */
name: string;
/** RPC endpoint URL */
rpcUrl: string;
/** Unique chain identifier */
chainId: number;
/** Block explorer URL */
scanUrl: string;
/** Network logo URL */
icon: string | undefined;
/** Whether this is a test network */
testnet: boolean;
/** Native currency information */
nativeCurrency: {
/** Number of decimal places */
decimals: number;
/** Full name of the currency */
name: string;
/** Currency symbol */
symbol: string;
/** Address of wrapped token contract */
wrappedAddress: string | undefined;
/** Currency logo URL (may differ from network icon) */
icon: string | undefined;
};
}
/** Interface defining optional configuration overrides for a Network instance */
interface NetworkOptions {
/** Override the default RPC URL */
rpcUrl?: string;
/** Override the default block explorer URL */
scanUrl?: string;
}
/**
* Network class that provides access to network-specific data and functionality
* Leverages network data provided through viem to make all relevant network fields
* accessible dynamically by chain ID.
*/
export declare class Network implements NetworkFields {
name: string;
rpcUrl: string;
chainId: number;
scanUrl: string;
client: PublicClient;
icon: string | undefined;
testnet: boolean;
nativeCurrency: {
decimals: number;
name: string;
symbol: string;
wrappedAddress: string | undefined;
icon: string | undefined;
};
/**
* Creates a new Network instance
*
* @param fields - Network configuration fields
*/
constructor({ name, rpcUrl, chainId, scanUrl, nativeCurrency, icon, }: NetworkFields);
/**
* Creates a Network instance from a chain ID
*
* @param chainId - The chain ID to create the network for
* @param options - Optional configuration overrides
* @returns A new Network instance
* @throws Error if the chain ID is not supported
*/
static fromChainId(chainId: number, options?: NetworkOptions): Network;
}
/**
* Checks if a given chain ID corresponds to a test network
*
* @param chainId - The chain ID to check
* @returns True if the network is a testnet, false otherwise
*/
export declare function isTestnet(chainId: number): boolean;
export {};