import type { Near } from "../core/near.js"; import type { CallOptions } from "../core/types.js"; /** * Utility type to automatically add options parameter to call methods. * * Usage: * ```typescript * type MyContract = Contract<{ * view: { * get_count: () => Promise * } * call: { * increment: (args: { amount: number }) => Promise * } * }> * ``` * * The call method will automatically get an options parameter: * increment: (args: { amount: number }, options?: CallOptions) => Promise */ export type Contract any>; call: Record any>; }> = { view: T["view"]; call: { [K in keyof T["call"]]: T["call"][K] extends (...args: infer TArgs) => infer TReturn ? TArgs extends [infer TFirstArg, ...infer _Rest] ? (args: TFirstArg, options?: CallOptions) => TReturn : (args?: undefined, options?: CallOptions) => TReturn : never; }; }; /** * Base contract method interface used by {@link Contract}. * * Methods can be defined as: * - View methods: (args?: ArgsType | Uint8Array, options?: BlockReference) => Promise * - Call methods: (args?: ArgsType | Uint8Array, options?: CallOptions) => Promise * * This is a base interface without index signatures to allow * extending interfaces to define specific method signatures with type safety. */ export interface ContractMethods { view: Record Promise>; call: Record Promise>; } /** * Create a type-safe contract proxy for a NEAR contract. * * @param near - The {@link Near} client instance to use for calls. * @param contractId - Account ID of the target contract. * * @returns A proxy implementing the given {@link ContractMethods} interface. * * @remarks * Prefer using {@link Near.contract} instead of calling this function directly. */ export declare function createContract(near: Near, contractId: string): T; /** * Helper to extend {@link Near} prototype with a `contract` method. * * @internal This is used to keep the core {@link Near} implementation focused; * library users should call {@link Near.contract} instead of using this helper. */ export declare function addContractMethod(nearPrototype: typeof Near.prototype): void; //# sourceMappingURL=contract.d.ts.map