import type { AbiFunction } from "viem";
import { type AnyCell, type CellArray, type MapCell, type SheetProxy } from "@okcontract/cells";
import type { CacheQuery } from "@okcontract/coredata";
import type { Environment } from "@okcontract/lambdascript";
import { type Address, type Chain, type ChainType, type EVMType, type Network, type StringAddress } from "@okcontract/multichain";
import type { Role, SignedMessage } from "@scv/auth";
import type { LocalSubscriber } from "@scv/cache";
import { type AppID } from "./constants";
import type { OKCore } from "./coreExecution";
import type { CompiledContract } from "./deploy";
export declare const METAMASK = "metamask";
export declare const INJECTED = "injected";
export declare const COINBASE = "coinbase";
export declare const LEDGER = "ledger";
export declare const SAFE = "safe";
export declare const MOCK = "mock";
export declare const WALLET_CONNECT = "walletConnect";
export declare const ARGENT = "argent";
export declare const RABBY = "rabby";
export declare const BRAVE = "brave";
export declare const TONW = "ton";
export declare const DEFAULT = "default";
export declare const connectorChain: {
    metamask: "evm";
    injected: "evm";
    argent: "strk";
    rabby: "evm";
    brave: "evm";
    ton: "ton";
    safe: "evm";
    ledger: "evm";
    coinbase: "evm";
    default: "evm";
};
export type WalletConnector = keyof typeof connectorChain;
export type connectorType<W extends WalletConnector> = (typeof connectorChain)[W];
export type WalletDetail = {
    conn: WalletConnector;
    name: AnyCell<string>;
    addr: MapCell<Address<Network>, true>;
    isVerified: AnyCell<boolean>;
    role?: AnyCell<Role>;
    /** anotherForeign */
    aF: AnyCell<boolean>;
};
export interface OKProvider {
    on(event: string, callback: (...args: unknown[]) => void): void;
    request(input: {
        method: string;
        params: unknown[];
    }): Promise<unknown>;
}
export type Transaction<N extends Network> = {
    chain: ChainType;
    chainId: bigint;
    value: bigint;
    to: StringAddress<N>;
    data: `0x${string}`;
    /** gas consumption limit */
    gas: `0x${string}`;
    maxFeePerGas?: bigint;
    maxPriorityFeePerGas?: bigint;
};
export type SignerFunction = (msg: string) => Promise<`0x${string}`>;
export declare enum SignerSource {
    Real = 0,
    Generated = 1
}
export type Signer<N extends Network> = {
    acc: StringAddress<N>;
    fn: SignerFunction;
    src: SignerSource;
};
export declare const newSigner: <N extends Network>(acc: StringAddress<N>, fn: SignerFunction, src: SignerSource) => Signer<N>;
export type SenderFunction<N extends Network> = (tx: Transaction<N>) => Promise<`0x${string}`>;
export interface OKConnector<N extends Network> {
    readonly ID: WalletConnector;
    readonly Network: Network;
    readonly Account: AnyCell<StringAddress<Network>>;
    readonly ChainId: AnyCell<number | bigint>;
    /** Current chain */
    readonly Chain: AnyCell<Chain>;
    /** supported chains */
    readonly Chains: AnyCell<Record<ChainType, Chain>>;
    readonly Addresses: AnyCell<StringAddress<N>[]>;
    connect(): Promise<{
        account: StringAddress<N>;
    }>;
    disconnect(): Promise<void>;
    switchChain?(id: ChainType): Promise<ChainType>;
    signMessage: SignerFunction;
    signedMessage: (msg: string) => Promise<SignedMessage>;
    sendTransaction: SenderFunction<N>;
    deployContract?(comp: CompiledContract, fn: AbiFunction, env: Environment): Promise<`0x${string}`>;
    addChain?(id: ChainType): Promise<ChainType>;
    signTransaction?(tx: Transaction<N>): Promise<`0x${string}`>;
}
export type DefaultConnectorOptions = {
    account: AnyCell<StringAddress<EVMType>>;
    chain?: AnyCell<Chain>;
    chains?: AnyCell<Record<ChainType, Chain>>;
    signer: SignerFunction;
    sender: SenderFunction<EVMType>;
};
export declare class DefaultConnectorEVM implements OKConnector<Network> {
    readonly ID: WalletConnector;
    readonly Network: "evm";
    readonly Account: AnyCell<StringAddress<EVMType>>;
    readonly ChainId: AnyCell<number | bigint>;
    readonly Chain: AnyCell<Chain>;
    readonly Chains: AnyCell<Record<ChainType, Chain>>;
    readonly Addresses: AnyCell<StringAddress<EVMType>[]>;
    private readonly _options;
    constructor(proxy: SheetProxy, options: DefaultConnectorOptions);
    connect(): Promise<{
        account: `0x${string}`;
    }>;
    disconnect(): Promise<void>;
    signMessage: SignerFunction;
    signedMessage: (Msg: string) => Promise<SignedMessage>;
    sendTransaction: SenderFunction<"evm">;
}
/**
 * privateKeyConnector transforms a private key into an OKConnector for
 * all supplied chains.
 */
export declare const privateKeyConnector: (core: OKCore, proxy: SheetProxy, chain: Chain, privateKey: `0x${string}`) => OKConnector<Network>;
export declare const missingChain: (err: Error & {
    code?: number;
}) => boolean;
export type ConnectorOptions = {
    local: LocalSubscriber<CacheQuery>;
    onConnect?: (account: StringAddress<Network>) => void;
    onDisconnect?: () => void;
};
export declare const connector: <W extends WalletConnector>(id: W, proxy: SheetProxy, chains: AnyCell<Record<ChainType, Chain>>, options?: ConnectorOptions) => OKConnector<connectorType<W>>;
/**
 * value_of formats values, using decimals for totalSupply.
 * @todo other use of decimals?
 * @todo "MAX" if more than 10^40?
 * @todo 2 digits precision
 * @todo https://docs.ethers.io/v5/api/utils/display-logic/
 * @todo use formatBig
 */
export declare const value_of: (name: string, v: string | number | bigint, decimals?: number) => any;
export declare const max_of: (v: number) => number | "MAX";
export declare const isRealWalletID: (walletID: Address<Network> | "loading") => walletID is Address<Network>;
/**
 * walletID is the current wallet.
 * @todo should not init empty
 */
export declare const NO_WALLET: any;
export declare const LOADING_WALLET: "loading";
export type WalletIDType = typeof LOADING_WALLET | Address<Network>;
export declare const ALL_CHAINS: "ALL";
export declare const detectWallet: (appID?: AppID) => WalletConnector;
export declare const detectWallets: (proxy: SheetProxy, appID?: AppID) => CellArray<WalletConnector>;
export declare const CODE_REQUIRED: "code";
export declare const AUTHENTICATING: "loading";
