js-moi-logic
Version:
Module to interact with MOI Logic Objects.
27 lines (24 loc) • 1.25 kB
TypeScript
import { LogicManifest } from "js-moi-manifest";
import { InteractionCallResponse, InteractionResponse } from "js-moi-providers";
import type { RoutineOption } from "../src.ts/routine-options";
export interface LogicIxRequest {
call: () => Promise<InteractionCallResponse>;
send: () => Promise<InteractionResponse>;
estimateFuel: () => Promise<number | bigint>;
unwrap: () => Promise<any>;
}
export interface Routine<T extends (...args: any[]) => any> {
/**
* Executes the logic interaction request with the specified routine and arguments.
* @param {...any[]} args - The arguments for the logic interaction request.
* @param {RoutineOption} option - The option for the logic interaction request.
* @returns {Promise<any>} a promise that resolves to the result of the logic interaction request.
*/
(...args: [...Parameters<T>, option?: RoutineOption]): ReturnType<T> | Promise<InteractionResponse>;
isMutable: () => boolean;
accepts: () => LogicManifest.TypeField[] | null;
returns: () => LogicManifest.TypeField[] | null;
}
export type Routines<T extends Record<string, (...args: any[]) => any>> = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? Routine<T[K]> : never;
}