import { ChainType, IXServiceBase, XToken } from '@sodax/types'; type XAccount = { address: string | undefined; xChainType: ChainType | undefined; publicKey?: string; }; type XConnection = { xAccount: XAccount; xConnectorId: string; }; /** * Public interface for chain service implementations. * * Consumer code should depend on this interface instead of the concrete XService class. * Extends the shared `IXServiceBase` from `@sodax/types` with wallet-sdk-react * specific connector methods. */ interface IXService extends IXServiceBase { getXConnectors(): IXConnector[]; getXConnectorById(xConnectorId: string): IXConnector | undefined; } /** * Public interface for wallet connector implementations. * * `isInstalled` reads `window.*` at getter-call time (render time); no extra * subscription is installed. Components get fresh values through normal React * render triggers (store updates, parent rerenders). */ interface IXConnector { readonly xChainType: ChainType; readonly name: string; /** Unique identifier for the connector */ readonly _id: string; /** Optional icon URL for the wallet provider */ readonly _icon?: string; readonly id: string; readonly icon: string | undefined; /** True when the wallet extension backing this connector is installed. */ readonly isInstalled: boolean; /** URL where users can install the wallet extension if missing. */ readonly installUrl: string | undefined; connect(): Promise; disconnect(): Promise; } /** * Abstract base class for blockchain service implementations. * * The XService class serves as a foundation for implementing blockchain-specific services * in a multi-chain environment. It provides a standardized interface for: * 1. Managing wallet connectors for different blockchain types * 2. Querying token balances across different chains * * Each blockchain implementation (e.g., Solana, EVM chains) extends this class * to provide chain-specific functionality while maintaining a consistent interface. * * @abstract * @class XService * @property {ChainType} xChainType - The blockchain type this service handles (e.g., 'SOLANA', 'EVM') * @property {XConnector[]} xConnectors - Available wallet connectors for this chain * */ declare abstract class XService implements IXServiceBase { /** The blockchain type this service handles */ readonly xChainType: ChainType; /** Available wallet connectors for this chain */ private xConnectors; constructor(xChainType: ChainType); /** * Gets the balance of a specific token for an address * @param address The wallet address to check * @param xToken The token to get the balance for * @returns Promise resolving to the token balance as a bigint */ getBalance(address: string | undefined, xToken: XToken): Promise; /** * Gets balances for multiple tokens for an address * @param address The wallet address to check * @param xTokens Array of tokens to get balances for * @returns Promise resolving to object mapping token addresses to balances */ getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise>; /** * Gets all available connectors for this chain */ getXConnectors(): IXConnector[]; /** * Sets the available connectors for this chain */ setXConnectors(xConnectors: IXConnector[]): void; /** * Gets a specific connector by its ID * @param xConnectorId The connector ID to look up * @returns The matching connector or undefined if not found */ getXConnectorById(xConnectorId: string): IXConnector | undefined; } /** * Base class for wallet provider connectors that handles connection management and wallet interactions * * @abstract * @class XConnector * @property {ChainType} xChainType - The blockchain type this connector supports * @property {string} name - Display name of the wallet provider * @property {string} _id - Unique identifier for the connector * @property {string | undefined} _icon - Optional icon URL for the wallet provider */ declare abstract class XConnector implements IXConnector { /** The blockchain type this connector supports */ readonly xChainType: ChainType; /** Display name of the wallet provider */ readonly name: string; /** Unique identifier for the connector */ readonly _id: string; /** Optional icon URL for the wallet provider */ readonly _icon?: string; constructor(xChainType: ChainType, name: string, id: string); /** * Connects to the wallet provider * @returns Promise resolving to the connected account, or undefined if connection fails */ abstract connect(): Promise; /** * Disconnects from the wallet provider */ abstract disconnect(): Promise; /** Get the unique identifier for this connector */ get id(): string; /** Get the optional icon URL for this wallet provider */ get icon(): string | undefined; /** * True when the wallet extension backing this connector is installed. * Default: true (for provider-managed chains where connector presence already * implies install — EVM via EIP-6963, Solana/Sui via adapter discovery). * Subclasses backed by extension injection (Bitcoin, ICON, Stacks) override * this with a window probe. */ get isInstalled(): boolean; /** URL to install the wallet extension when missing. Subclasses override. */ get installUrl(): string | undefined; } export { type IXConnector as I, type XAccount as X, type IXService as a, type XConnection as b, XConnector as c, XService as d };