UNPKG

@nfps.dev/cli

Version:

CLI for NFP development, inspection, and manipulation

47 lines (46 loc) 2.79 kB
import type { If } from 'ts-toolbelt/out/Any/If'; import type { Includes } from 'ts-toolbelt/out/List/Includes'; import type { Merge } from 'ts-toolbelt/out/Object/Merge'; import type { Dict, JsonObject, Nilable } from '@blake.regalia/belt'; import type { SecretAccAddr, Snip821 } from '@solar-republic/contractor'; import type { ArgumentsCamelCase, InferredOptionTypes, Options, PositionalOptions } from 'yargs'; import { SecretApp, type AuthSecret } from '@solar-republic/neutrino'; import { query_contract_infer, SecretContract, Wallet, exec_contract } from '@solar-republic/neutrino'; import { type H_OPTS_EXEC } from './constants.js'; export type TxOpts = ArgumentsCamelCase<InferredOptionTypes<typeof H_OPTS_EXEC>>; export type Command<g_opts extends Dict<Options> = {}, g_pos extends Dict<PositionalOptions> = {}> = { info: string; commands?: any; opts?: g_opts; pos?: g_pos; handler?: (g_argv: TxOpts & ArgumentsCamelCase<Merge<InferredOptionTypes<g_opts>, InferredOptionTypes<g_pos>>>) => void | Promise<void>; }; export declare function define_command<g_opts extends Dict<Options> = {}, g_pos extends Dict<PositionalOptions> = {}>(gc_cmd: Command<g_opts, g_pos>): typeof gc_cmd; export declare const debug: (s_out: string) => void; export declare const result: (s_out: string) => void; export declare const print: (s_header: string, h_fields?: object) => void; export declare const exit: (s_error: string) => never; export declare function load<a_reqs extends Array<'vk' | 'token-id'>>(g_argv?: Dict<unknown>, // Record<keyof typeof H_OPTS_EXEC, Nilable<boolean | number | string>>, a_reqs?: a_reqs): Promise<{ sh_sk: string; sh_vk: If<Includes<a_reqs, 'vk'>, string, undefined>; si_chain: string | undefined; a_lcds: string[]; a_rpcs: string[]; sa_contract: SecretAccAddr | undefined; si_token: If<Includes<a_reqs, 'token-id'>, string, undefined>; k_contract: SecretContract<Snip821>; k_service: SecretApp<Snip821>; k_wallet: Wallet; }>; /** * parses a cli option value as JSON or simplified key-value * e.g., --entry "key: 'value'" */ export declare function cli_entries(sx_entry: string): JsonObject; export declare function env_exists(): Promise<boolean>; export declare function check_writable_env(): Promise<void>; export declare function mutate_env(h_replacements: Dict): Promise<void>; export declare function cli_query_contract(g_argv: TxOpts, si_query: string, h_args?: Nilable<JsonObject>, z_auth?: Nilable<AuthSecret>): Promise<ReturnType<typeof query_contract_infer>>; export declare function cli_exec_contract(g_argv: TxOpts, g_msg: JsonObject, xg_limit: bigint, r_debug?: RegExp): Promise<ReturnType<typeof exec_contract>>; export declare function validate_bech32(sa_input: string): true | string;