@phala/cloud
Version:
TypeScript SDK for Phala Cloud API
44 lines • 1.71 kB
TypeScript
import { type Chain, type Hash } from "viem";
import { type NetworkClients } from "./network";
interface EthereumProvider {
request: (args: {
method: string;
params?: unknown[];
}) => Promise<unknown>;
on?(event: string, handler: (...args: unknown[]) => void): void;
removeListener?(event: string, handler: (...args: unknown[]) => void): void;
}
/**
* CONVENIENCE: Create clients from private key (server-side)
* You can also create your own viem clients and use createNetworkClients() directly
*/
export declare function createClientsFromPrivateKey(chain: Chain, privateKey: Hash, rpcUrl?: string): NetworkClients;
/**
* CONVENIENCE: Create clients from browser wallet (client-side)
* You can also create your own viem clients and use createNetworkClients() directly
*/
export declare function createClientsFromBrowser(chain: Chain, rpcUrl?: string): Promise<NetworkClients>;
/**
* CONVENIENCE: Switch to a specific network in browser wallet
*/
export declare function switchToNetwork(provider: EthereumProvider, chainId: number): Promise<void>;
/**
* CONVENIENCE: Add a custom network to browser wallet
*/
export declare function addNetwork(provider: EthereumProvider, config: {
chainId: number;
name: string;
rpcUrl: string;
blockExplorer?: string;
}): Promise<void>;
/**
* CONVENIENCE: Auto-detect environment and create clients
* You can also create your own viem clients and use createNetworkClients() directly
*/
export declare function autoCreateClients(chain: Chain, options?: {
privateKey?: Hash;
rpcUrl?: string;
preferBrowser?: boolean;
}): Promise<NetworkClients>;
export {};
//# sourceMappingURL=client-factories.d.ts.map