@pushchain/core
Version:
## Overview
110 lines (109 loc) • 4.08 kB
TypeScript
import { CHAIN, PUSH_NETWORK } from '../constants/enums';
import { Orchestrator } from '../orchestrator/orchestrator';
import { UniversalAccount, UniversalSigner } from '../universal/universal.types';
import { Utils } from '../utils';
import { TypedData, TypedDataDomain } from 'viem';
import { ProgressEvent } from '../progress-hook/progress-hook.types';
/**
* @class PushChain
*
* Entry point to interact with Push Chain in your application.
* Provides access to cross-chain execution, utilities, and signer abstraction.
*/
export declare class PushChain {
private orchestrator;
private universalSigner;
private blockExplorers;
isReadMode: boolean;
/**
* @static
* Constants for the PushChain SDK.
*/
static CONSTANTS: {
PUSH_NETWORK: typeof PUSH_NETWORK;
CHAIN: typeof CHAIN;
LIBRARY: typeof import("../constants/enums").LIBRARY;
};
/**
* @static
* Utility functions for encoding, hashing, and data formatting.
*/
static utils: typeof Utils;
/**
* Helper function to check if input is UniversalAccount (read-only) or UniversalSigner
*/
private static isUniversalAccount;
/**
* Universal namespace containing core transaction and address computation methods
*/
universal: {
get origin(): ReturnType<Orchestrator['getUOA']>;
get account(): ReturnType<Orchestrator['computeUEAOffchain']>;
/**
* Executes a transaction on Push Chain
*/
sendTransaction: Orchestrator['execute'];
/**
* Signs an arbitrary message
*/
signMessage: (data: Uint8Array) => Promise<string>;
/**
* Signs EIP-712 typed data
*/
signTypedData: ({ domain, types, primaryType, message, }: {
domain: TypedDataDomain;
types: TypedData;
primaryType: string;
message: Record<string, any>;
}) => Promise<string>;
};
explorer: {
getTransactionUrl: (txHash: string) => string;
listUrls: () => string[];
};
private constructor();
/**
* @private
* Internal method to create a PushChain instance with the given parameters.
* Used by both initialize and reinitialize methods to avoid code duplication.
*/
private static createInstance;
/**
* @method initialize
* Initializes the PushChain SDK with a universal signer and optional config.
*
* @param universalSigner
* @param options - Optional settings to configure the SDK instance.
* - network: PushChain network to target (e.g., TESTNET_DONUT, MAINNET).
* - rpcUrls: Custom RPC URLs mapped by chain IDs.
* - printTraces: Whether to print internal trace logs for debugging.
*
* @returns An initialized instance of PushChain.
*/
static initialize: (universalSigner: UniversalSigner | UniversalAccount, options?: {
network: PUSH_NETWORK;
rpcUrls?: Partial<Record<CHAIN, string[]>>;
blockExplorers?: Partial<Record<CHAIN, string[]>>;
printTraces?: boolean;
progressHook?: (progress: ProgressEvent) => void;
}) => Promise<PushChain>;
/**
* @method reinitialize
* Reinitializes the PushChain SDK with a new universal signer and optional config.
*
* @param universalSigner
* @param options - Optional settings to configure the SDK instance.
* - network: PushChain network to target (e.g., TESTNET_DONUT, MAINNET).
* - rpcUrls: Custom RPC URLs mapped by chain IDs.
* - printTraces: Whether to print internal trace logs for debugging.
*
* @returns A new initialized instance of PushChain.
*/
reinitialize: (universalSigner: UniversalSigner | UniversalAccount, options?: {
network: PUSH_NETWORK;
rpcUrls?: Partial<Record<CHAIN, string[]>>;
blockExplorers?: Partial<Record<CHAIN, string[]>>;
printTraces?: boolean;
progressHook?: (progress: ProgressEvent) => void;
}) => Promise<PushChain>;
}