UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

90 lines • 3.8 kB
import { OutputKind, TypedLiteral, TypedRef } from "../types.js"; import { AppliedGuard, SolType } from "@lifi/compose-spec"; //#region src/authoring/raw.d.ts /** * Creates a typed `$ref` pointer for use in bind slots. * * This is an **escape hatch** for referencing values that the typed builder * API doesn't cover — for example, outputs of an `untypedOp` node or custom * context paths. The caller is responsible for choosing the correct type * parameter; no runtime validation occurs. * * Prefer typed handles (`OutputHandle`, `InputHandle`) and `builder.context` * whenever possible. Use `ref` only when you need to construct a `$ref` path * manually and want it accepted by a `Bindable<T>` slot. * * @typeParam T - The output kind this ref represents (e.g. `'address'`, `'uint256'`, `'resource'`). * @param path - The `$ref` path (e.g. `"context.sender"`, `"myNode.result"`). * @returns A {@link TypedRef} accepted by `Bindable<T>` slots matching `T`. * * @example * ```ts * import { raw } from '@lifi/composer-sdk'; * * // Reference an untypedOp output in a typed operation: * builder.untypedOp('custom', 'some.op', { * bind: { x: { $ref: 'input.token' } }, * config: {}, * }); * builder.core.add('sum', { * bind: { * a: raw.ref<'uint256'>('custom.result'), * b: someTypedHandle, * }, * }); * ``` */ export declare const ref: <T extends OutputKind>(path: string) => TypedRef<T>; /** * Creates a typed literal for use in bind slots: a constant baked into the * flow document rather than supplied at run time. * * Prefer a declared flow input and `builder.inputs.<name>` — a value the * caller supplies per run stays out of the document. Use a literal for a * constant that belongs to the document itself, such as a fixed treasury * address. * * Never use a literal for the payee of a `continuation.settle` leg * (`continuationFlow`). The leg produces its outcome into its own proxy * (`leg.context.executionAddress`) and names no recipient; the composer * appends a settlement epilogue at commit that forwards the outcome to the * provider's recipient and the residual to `refund`. A call argument inside * the leg (the payee of an invoice the leg pays through `core.call`) is not * that recipient and may be a literal. * * In a `core.call` / `core.staticCall` bind, `kind` must equal the parameter's * Solidity type exactly, and `value` must encode as that type: a decimal or * `0x` integer, `'true'` / `'false'`, a `0x` address (mixed case only with a * valid checksum), or a `0x` hex byte string of the right length. * * @typeParam T - The Solidity type of the literal (e.g. `'address'`). * @param kind - The literal's Solidity type. * @param value - The literal value, as the wire format carries it: a string. * @returns A {@link TypedLiteral} accepted by `Bindable<T>` slots matching `T` * and by `core.call` / `core.staticCall` parameters of type `T`. * * @example * ```ts * import { raw } from '@lifi/composer-sdk'; * * // A fixed fee to a treasury baked into the flow document. * builder.core.transfer('fee', { * bind: { * amount: builder.inputs.fee, * recipient: raw.literal('address', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'), * }, * config: {}, * }); * ``` */ export declare const literal: <T extends SolType>(kind: T, value: string) => TypedLiteral<T>; /** * Creates a raw guard object for use in the `guards` array of an operation call. * * @param kind - The guard type (e.g. `"slippage"`). * @param config - Guard-specific configuration (e.g. `{ toleranceBps: 300 }`). * @returns An {@link AppliedGuard} object. */ export declare const rawGuard: (kind: string, config?: Record<string, unknown>) => AppliedGuard; //#endregion //# sourceMappingURL=raw.d.ts.map