@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
48 lines (45 loc) • 1.76 kB
text/typescript
import { AppliedGuard } from '@lifi/compose-spec';
import { OutputKind, TypedRef } from '../types.cjs';
/**
* 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,
* },
* });
* ```
*/
declare const ref: <T extends OutputKind>(path: string) => TypedRef<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.
*/
declare const rawGuard: (kind: string, config?: Record<string, unknown>) => AppliedGuard;
export { rawGuard, ref };