UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

59 lines (58 loc) • 2.01 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); // src/run/inputs.ts /** * Creates an untyped materialiser input spec. This is a low-level escape hatch * for materialiser kinds not yet covered by the generated helpers. * * Prefer the typed helpers in the `materialisers` namespace (e.g. * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide * compile-time config validation. * * @param kind - The materialiser type (e.g. `"balanceOf"`, `"directDeposit"`). * @param config - Optional materialiser-specific configuration. * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}. * * @example * ```ts * const run = { * inputs: { token: materialiser('customKind', { myParam: '0x...' }) }, * signer: '0x...', * }; * ``` */ const materialiser = (kind, config = {}) => ({ kind, ...config }); /** * Drops the keys whose value is `undefined`, so optional fields are omitted * from the wire payload rather than serialized as `null`. * * A local copy of `pickDefined` from `@lifi/utils`: this package is published * to npm and `@lifi/utils` is a private workspace package, so it cannot be a * runtime dependency here. */ const pickDefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0)); /** * Assembles a {@link ComposeRun} object from individual parameters. * Used internally by the SDK; prefer {@link ComposeRunInput} for external use. * * @internal */ const buildRun = (run) => ({ inputs: run.inputs, signer: run.signer, ...pickDefined({ preconditions: run.preconditions?.length ? run.preconditions : void 0, assumptions: run.assumptions, referrer: run.referrer, maxPriceImpactBps: run.maxPriceImpactBps, sweepTo: run.sweepTo, simulationPolicy: run.simulationPolicy, simulateUserProgram: run.simulateUserProgram, checkOnChainAllowances: run.checkOnChainAllowances }) }); exports.buildRun = buildRun; exports.materialiser = materialiser; //# sourceMappingURL=inputs.cjs.map