@lifi/composer-sdk 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/authoring/FlowBuilderCore.cjs +102 -120
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
- package/dist/authoring/FlowBuilderCore.d.cts +58 -61
- package/dist/authoring/FlowBuilderCore.d.ts +58 -61
- package/dist/authoring/FlowBuilderCore.js +99 -97
- package/dist/authoring/FlowBuilderCore.js.map +1 -1
- package/dist/authoring/handles.cjs +25 -40
- package/dist/authoring/handles.cjs.map +1 -1
- package/dist/authoring/handles.d.cts +33 -34
- package/dist/authoring/handles.d.ts +33 -34
- package/dist/authoring/handles.js +21 -13
- package/dist/authoring/handles.js.map +1 -1
- package/dist/authoring/raw.cjs +85 -44
- package/dist/authoring/raw.cjs.map +1 -1
- package/dist/authoring/raw.d.cts +8 -8
- package/dist/authoring/raw.d.ts +8 -8
- package/dist/authoring/raw.js +83 -19
- package/dist/authoring/raw.js.map +1 -1
- package/dist/authoring/signatureArgs.cjs +81 -103
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.d.cts +63 -64
- package/dist/authoring/signatureArgs.d.ts +63 -64
- package/dist/authoring/signatureArgs.js +76 -75
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +172 -220
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +131 -131
- package/dist/client.d.ts +131 -131
- package/dist/client.js +165 -198
- package/dist/client.js.map +1 -1
- package/dist/discovery.cjs +0 -17
- package/dist/discovery.d.cts +57 -56
- package/dist/discovery.d.ts +57 -56
- package/dist/discovery.js +1 -1
- package/dist/errors.cjs +211 -159
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +84 -84
- package/dist/errors.d.ts +84 -84
- package/dist/errors.js +201 -120
- package/dist/errors.js.map +1 -1
- package/dist/generated/config.generated.cjs +0 -17
- package/dist/generated/config.generated.d.cts +804 -936
- package/dist/generated/config.generated.d.ts +804 -936
- package/dist/generated/config.generated.js +1 -1
- package/dist/generated/guards.generated.cjs +25 -35
- package/dist/generated/guards.generated.cjs.map +1 -1
- package/dist/generated/guards.generated.d.cts +20 -4
- package/dist/generated/guards.generated.d.ts +20 -4
- package/dist/generated/guards.generated.js +19 -11
- package/dist/generated/guards.generated.js.map +1 -1
- package/dist/generated/materialisers.generated.cjs +25 -35
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +17 -4
- package/dist/generated/materialisers.generated.d.ts +17 -4
- package/dist/generated/materialisers.generated.js +19 -11
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +236 -277
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +719 -708
- package/dist/generated/operations.generated.d.ts +719 -708
- package/dist/generated/operations.generated.js +235 -256
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/generated/preconditions.generated.cjs +25 -35
- package/dist/generated/preconditions.generated.cjs.map +1 -1
- package/dist/generated/preconditions.generated.d.cts +17 -4
- package/dist/generated/preconditions.generated.d.ts +17 -4
- package/dist/generated/preconditions.generated.js +19 -11
- package/dist/generated/preconditions.generated.js.map +1 -1
- package/dist/index.cjs +131 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -43
- package/dist/index.d.ts +29 -43
- package/dist/index.js +96 -45
- package/dist/index.js.map +1 -1
- package/dist/outputs.cjs +11 -32
- package/dist/outputs.cjs.map +1 -1
- package/dist/outputs.d.cts +5 -5
- package/dist/outputs.d.ts +5 -5
- package/dist/outputs.js +10 -8
- package/dist/outputs.js.map +1 -1
- package/dist/raw.cjs +21 -33
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.d.cts +8 -4
- package/dist/raw.d.ts +8 -4
- package/dist/raw.js +12 -7
- package/dist/raw.js.map +1 -1
- package/dist/reachability.cjs +82 -112
- package/dist/reachability.cjs.map +1 -1
- package/dist/reachability.d.cts +33 -59
- package/dist/reachability.d.ts +33 -59
- package/dist/reachability.js +81 -88
- package/dist/reachability.js.map +1 -1
- package/dist/resources.cjs +47 -32
- package/dist/resources.cjs.map +1 -1
- package/dist/resources.d.cts +50 -3
- package/dist/resources.d.ts +50 -3
- package/dist/resources.js +42 -9
- package/dist/resources.js.map +1 -1
- package/dist/responseSchemas.cjs +99 -111
- package/dist/responseSchemas.cjs.map +1 -1
- package/dist/responseSchemas.d.cts +34 -34
- package/dist/responseSchemas.d.ts +34 -34
- package/dist/responseSchemas.js +85 -66
- package/dist/responseSchemas.js.map +1 -1
- package/dist/routeAmount.cjs +61 -31
- package/dist/routeAmount.cjs.map +1 -1
- package/dist/routeAmount.d.cts +52 -2
- package/dist/routeAmount.d.ts +52 -2
- package/dist/routeAmount.js +56 -8
- package/dist/routeAmount.js.map +1 -1
- package/dist/run/inputs.cjs +56 -48
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +70 -74
- package/dist/run/inputs.d.ts +70 -74
- package/dist/run/inputs.js +54 -23
- package/dist/run/inputs.js.map +1 -1
- package/dist/run/simulate.cjs +38 -43
- package/dist/run/simulate.cjs.map +1 -1
- package/dist/run/simulate.d.cts +36 -36
- package/dist/run/simulate.d.ts +36 -36
- package/dist/run/simulate.js +37 -19
- package/dist/run/simulate.js.map +1 -1
- package/dist/sdk.cjs +55 -66
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +108 -111
- package/dist/sdk.d.ts +108 -111
- package/dist/sdk.js +52 -44
- package/dist/sdk.js.map +1 -1
- package/dist/types.cjs +0 -17
- package/dist/types.d.cts +22 -22
- package/dist/types.d.ts +22 -22
- package/dist/types.js +1 -1
- package/package.json +5 -5
- package/src/client.ts +2 -2
- package/src/examples/aaveClaimRewards.ts +2 -1
- package/src/examples/emitCustomEvent.ts +1 -2
- package/src/examples/run.ts +1 -1
- package/src/examples/transferTokens.ts +21 -17
- package/src/generated/config.generated.ts +20 -9
- package/src/generated/operations.generated.ts +28 -5
- package/dist/discovery.cjs.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/generated/config.generated.cjs.map +0 -1
- package/dist/generated/config.generated.js.map +0 -1
- package/dist/guards.generated-CDCgYGZo.d.cts +0 -24
- package/dist/guards.generated-CdYcs4h0.d.ts +0 -24
- package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
- package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
- package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
- package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
- package/dist/raw-BvRghN3r.d.ts +0 -20
- package/dist/raw-s1rer8X3.d.cts +0 -20
- package/dist/resources-BKlFxjo8.d.cts +0 -56
- package/dist/resources-CYis1_DS.d.ts +0 -56
- package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
- package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
- package/dist/types.cjs.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,53 +1,104 @@
|
|
|
1
|
+
import { isComposeError, isComposePreparationError, isComposeSdkOutdatedError, isComposeServerOutdatedError } from "./errors.js";
|
|
1
2
|
import { buildReachability } from "./reachability.js";
|
|
2
|
-
import {
|
|
3
|
-
SIMULATE_MAX_TRACKED_BALANCES,
|
|
4
|
-
SIMULATE_MAX_REQUIREMENTS
|
|
5
|
-
} from "@lifi/compose-spec";
|
|
6
|
-
import {
|
|
7
|
-
isComposeError,
|
|
8
|
-
isComposePreparationError,
|
|
9
|
-
isComposeSdkOutdatedError,
|
|
10
|
-
isComposeServerOutdatedError
|
|
11
|
-
} from "./errors.js";
|
|
12
3
|
import { isInputHandle, isOutputHandle } from "./authoring/handles.js";
|
|
13
4
|
import { ref } from "./authoring/raw.js";
|
|
14
5
|
import { materialiser } from "./run/inputs.js";
|
|
15
6
|
import { buildSimulateRequest } from "./run/simulate.js";
|
|
16
7
|
import { terminalOutputs } from "./outputs.js";
|
|
17
8
|
import { createComposeSdk } from "./sdk.js";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
9
|
+
import { guards_generated_exports } from "./generated/guards.generated.js";
|
|
10
|
+
import { materialisers_generated_exports } from "./generated/materialisers.generated.js";
|
|
11
|
+
import { preconditions_generated_exports } from "./generated/preconditions.generated.js";
|
|
12
|
+
import { raw_exports } from "./raw.js";
|
|
13
|
+
import { resources_exports } from "./resources.js";
|
|
14
|
+
import { routeAmount_exports } from "./routeAmount.js";
|
|
15
|
+
import { SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES } from "@lifi/compose-spec";
|
|
16
|
+
//#region src/index.ts
|
|
17
|
+
/**
|
|
18
|
+
* Guard factories for protecting operation outputs (e.g. slippage tolerance).
|
|
19
|
+
* Pass guards to an operation's `guards` array.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* builder.lifi.swap('swap1', {
|
|
24
|
+
* bind: { amountIn: builder.inputs.token },
|
|
25
|
+
* config: { resourceOut: resources.native(1) },
|
|
26
|
+
* guards: [guards.slippage({ port: 'amountOut', bps: 300 })],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const guards = guards_generated_exports;
|
|
31
|
+
/**
|
|
32
|
+
* Materialiser factories that tell the runtime how to resolve token input
|
|
33
|
+
* amounts on-chain (e.g. read a wallet balance, accept a direct deposit).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* await builder.compile({
|
|
38
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
39
|
+
* signer: '0x...',
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
const materialisers = materialisers_generated_exports;
|
|
44
|
+
/**
|
|
45
|
+
* Precondition factories for asserting on-chain state before a flow executes
|
|
46
|
+
* (e.g. minimum token balances, ERC-20 allowances).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* await builder.compile({
|
|
51
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
52
|
+
* preconditions: [
|
|
53
|
+
* preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),
|
|
54
|
+
* ],
|
|
55
|
+
* signer: '0x...',
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
const preconditions = preconditions_generated_exports;
|
|
60
|
+
/**
|
|
61
|
+
* Resource declaration helpers for defining token inputs in a flow schema.
|
|
62
|
+
* Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}
|
|
63
|
+
* for the chain's native coin (ETH, MATIC, etc.).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const builder = sdk.flow(1, {
|
|
68
|
+
* inputs: {
|
|
69
|
+
* usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),
|
|
70
|
+
* eth: resources.native(1),
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
const resources = resources_exports;
|
|
76
|
+
/**
|
|
77
|
+
* Amount constructors for {@link ComposeSdk.route}. Use
|
|
78
|
+
* {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and
|
|
79
|
+
* {@link routeAmount.all} to spend the signer's whole balance.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.
|
|
84
|
+
* const result = await sdk.route({
|
|
85
|
+
* chainId: 1,
|
|
86
|
+
* fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
87
|
+
* toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',
|
|
88
|
+
* amount: routeAmount.exact(1_000_000n),
|
|
89
|
+
* signer: '0xYourAddress...',
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
const routeAmount = routeAmount_exports;
|
|
94
|
+
/**
|
|
95
|
+
* Low-level escape hatch for constructing flow nodes, guards, and materialiser
|
|
96
|
+
* inputs without the typed builder API. Prefer the generated operation methods
|
|
97
|
+
* on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces
|
|
98
|
+
* for most use cases.
|
|
99
|
+
*/
|
|
100
|
+
const raw = raw_exports;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, buildReachability, buildSimulateRequest, createComposeSdk, guards, isComposeError, isComposePreparationError, isComposeSdkOutdatedError, isComposeServerOutdatedError, isInputHandle, isOutputHandle, materialiser, materialisers, preconditions, raw, ref, resources, routeAmount, terminalOutputs };
|
|
103
|
+
|
|
53
104
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n TypedLiteral,\n} from './types.js';\n\nexport type {\n ChainSummary,\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n Reachability,\n ReachabilityOptions,\n RoutablePair,\n TokenRef,\n} from './reachability.js';\nexport { buildReachability } from './reachability.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposeSdkOutdated,\n ComposeServerOutdated,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeAction,\n ComposeFill,\n ComposeFee,\n ComposeUserProgramSimulation,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeErrorKind,\n ComposeRouteRequest,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n OutputAmount,\n Amount,\n ConsumedOutput,\n Delivery,\n Estimate,\n EstimateBasis,\n Minimum,\n MinimumBasis,\n Output,\n Outputs,\n TerminalOutput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n RouteAmount,\n RouteAmountAll,\n RouteAmountExact,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n SettlementWire,\n SettlementEscrowWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport {\n isComposeError,\n isComposePreparationError,\n isComposeSdkOutdatedError,\n isComposeServerOutdatedError,\n} from './errors.js';\n\nexport type {\n Bindable,\n RefBindable,\n AnyRefBindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n OutputFamilyHandles,\n FamilyCount,\n FamilySource,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { terminalOutputs } from './outputs.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\nimport * as routeAmountMod from './routeAmount.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\n/**\n * Amount constructors for {@link ComposeSdk.route}. Use\n * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and\n * {@link routeAmount.all} to spend the signer's whole balance.\n *\n * @example\n * ```ts\n * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',\n * amount: routeAmount.exact(1_000_000n),\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport const routeAmount: typeof routeAmountMod = routeAmountMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["guardsMod","materialisersMod","preconditionsMod","resourcesMod","routeAmountMod","rawMod"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n TypedLiteral,\n} from './types.js';\n\nexport type {\n ChainSummary,\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type {\n Reachability,\n ReachabilityOptions,\n RoutablePair,\n TokenRef,\n} from './reachability.js';\nexport { buildReachability } from './reachability.js';\nexport type {\n ComposeError,\n ComposeErrorCode,\n ComposeSdkOutdated,\n ComposeServerOutdated,\n ComposePreparationOps,\n} from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeAction,\n ComposeFill,\n ComposeFee,\n ComposeUserProgramSimulation,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeErrorKind,\n ComposeRouteRequest,\n ComposeTransactionRequest,\n FailedPreparedOp,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n OutputAmount,\n Amount,\n ConsumedOutput,\n Delivery,\n Estimate,\n EstimateBasis,\n Minimum,\n MinimumBasis,\n Output,\n Outputs,\n TerminalOutput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n RouteAmount,\n RouteAmountAll,\n RouteAmountExact,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n SettlementWire,\n SettlementEscrowWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport {\n isComposeError,\n isComposePreparationError,\n isComposeSdkOutdatedError,\n isComposeServerOutdatedError,\n} from './errors.js';\n\nexport type {\n Bindable,\n RefBindable,\n AnyRefBindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n OutputFamilyHandles,\n FamilyCount,\n FamilySource,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { terminalOutputs } from './outputs.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\nimport * as routeAmountMod from './routeAmount.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\n/**\n * Amount constructors for {@link ComposeSdk.route}. Use\n * {@link routeAmount.exact} to spend a fixed amount of the `fromToken`, and\n * {@link routeAmount.all} to spend the signer's whole balance.\n *\n * @example\n * ```ts\n * // USDC into the Aave v3 aEthUSDC position — one routing-catalog edge.\n * const result = await sdk.route({\n * chainId: 1,\n * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * toToken: '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c',\n * amount: routeAmount.exact(1_000_000n),\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport const routeAmount: typeof routeAmountMod = routeAmountMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,MAAa,SAA2BA;;;;;;;;;;;;;AAaxC,MAAa,gBAAyCC;;;;;;;;;;;;;;;;AAgBtD,MAAa,gBAAyCC;;;;;;;;;;;;;;;;AAgBtD,MAAa,YAAiCC;;;;;;;;;;;;;;;;;;AAkB9C,MAAa,cAAqCC;;;;;;;AASlD,MAAa,MAAqBC"}
|
package/dist/outputs.cjs
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var outputs_exports = {};
|
|
20
|
-
__export(outputs_exports, {
|
|
21
|
-
terminalOutputs: () => terminalOutputs
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(outputs_exports);
|
|
24
|
-
const terminalOutputs = (outputs) => Object.fromEntries(
|
|
25
|
-
Object.entries(outputs).filter(
|
|
26
|
-
(entry) => entry[1].role === "terminal"
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
terminalOutputs
|
|
32
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/outputs.ts
|
|
3
|
+
/**
|
|
4
|
+
* The entries of `outputs` the caller actually receives: every port no later
|
|
5
|
+
* node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports
|
|
6
|
+
* (intermediate amounts a later op takes as input) are dropped.
|
|
7
|
+
*/
|
|
8
|
+
const terminalOutputs = (outputs) => Object.fromEntries(Object.entries(outputs).filter((entry) => entry[1].role === "terminal"));
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.terminalOutputs = terminalOutputs;
|
|
11
|
+
|
|
33
12
|
//# sourceMappingURL=outputs.cjs.map
|
package/dist/outputs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/outputs.ts"],"sourcesContent":["import type { Outputs, TerminalOutput } from '@lifi/compose-spec';\n\n/**\n * The entries of `outputs` the caller actually receives: every port no later\n * node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports\n * (intermediate amounts a later op takes as input) are dropped.\n */\nexport const terminalOutputs = (\n outputs: Outputs,\n): Record<string, TerminalOutput> =>\n Object.fromEntries(\n Object.entries(outputs).filter(\n (entry): entry is [string, TerminalOutput] =>\n entry[1].role === 'terminal',\n ),\n );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"outputs.cjs","names":[],"sources":["../src/outputs.ts"],"sourcesContent":["import type { Outputs, TerminalOutput } from '@lifi/compose-spec';\n\n/**\n * The entries of `outputs` the caller actually receives: every port no later\n * node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports\n * (intermediate amounts a later op takes as input) are dropped.\n */\nexport const terminalOutputs = (\n outputs: Outputs,\n): Record<string, TerminalOutput> =>\n Object.fromEntries(\n Object.entries(outputs).filter(\n (entry): entry is [string, TerminalOutput] =>\n entry[1].role === 'terminal',\n ),\n );\n"],"mappings":";;;;;;;AAOA,MAAa,mBACX,YAEA,OAAO,YACL,OAAO,QAAQ,OAAO,CAAC,CAAC,QACrB,UACC,MAAM,EAAE,CAAC,SAAS,UACtB,CACF"}
|
package/dist/outputs.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Outputs, TerminalOutput } from
|
|
2
|
-
|
|
1
|
+
import { Outputs, TerminalOutput } from "@lifi/compose-spec";
|
|
2
|
+
//#region src/outputs.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The entries of `outputs` the caller actually receives: every port no later
|
|
5
5
|
* node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports
|
|
6
6
|
* (intermediate amounts a later op takes as input) are dropped.
|
|
7
7
|
*/
|
|
8
|
-
declare const terminalOutputs: (outputs: Outputs) => Record<string, TerminalOutput>;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare const terminalOutputs: (outputs: Outputs) => Record<string, TerminalOutput>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=outputs.d.cts.map
|
package/dist/outputs.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Outputs, TerminalOutput } from
|
|
2
|
-
|
|
1
|
+
import { Outputs, TerminalOutput } from "@lifi/compose-spec";
|
|
2
|
+
//#region src/outputs.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The entries of `outputs` the caller actually receives: every port no later
|
|
5
5
|
* node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports
|
|
6
6
|
* (intermediate amounts a later op takes as input) are dropped.
|
|
7
7
|
*/
|
|
8
|
-
declare const terminalOutputs: (outputs: Outputs) => Record<string, TerminalOutput>;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare const terminalOutputs: (outputs: Outputs) => Record<string, TerminalOutput>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=outputs.d.ts.map
|
package/dist/outputs.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
//#region src/outputs.ts
|
|
2
|
+
/**
|
|
3
|
+
* The entries of `outputs` the caller actually receives: every port no later
|
|
4
|
+
* node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports
|
|
5
|
+
* (intermediate amounts a later op takes as input) are dropped.
|
|
6
|
+
*/
|
|
7
|
+
const terminalOutputs = (outputs) => Object.fromEntries(Object.entries(outputs).filter((entry) => entry[1].role === "terminal"));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { terminalOutputs };
|
|
10
|
+
|
|
9
11
|
//# sourceMappingURL=outputs.js.map
|
package/dist/outputs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/outputs.ts"],"sourcesContent":["import type { Outputs, TerminalOutput } from '@lifi/compose-spec';\n\n/**\n * The entries of `outputs` the caller actually receives: every port no later\n * node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports\n * (intermediate amounts a later op takes as input) are dropped.\n */\nexport const terminalOutputs = (\n outputs: Outputs,\n): Record<string, TerminalOutput> =>\n Object.fromEntries(\n Object.entries(outputs).filter(\n (entry): entry is [string, TerminalOutput] =>\n entry[1].role === 'terminal',\n ),\n );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"outputs.js","names":[],"sources":["../src/outputs.ts"],"sourcesContent":["import type { Outputs, TerminalOutput } from '@lifi/compose-spec';\n\n/**\n * The entries of `outputs` the caller actually receives: every port no later\n * node spends, keyed `<nodeId>.<portName>` as on the wire. Consumed ports\n * (intermediate amounts a later op takes as input) are dropped.\n */\nexport const terminalOutputs = (\n outputs: Outputs,\n): Record<string, TerminalOutput> =>\n Object.fromEntries(\n Object.entries(outputs).filter(\n (entry): entry is [string, TerminalOutput] =>\n entry[1].role === 'terminal',\n ),\n );\n"],"mappings":";;;;;;AAOA,MAAa,mBACX,YAEA,OAAO,YACL,OAAO,QAAQ,OAAO,CAAC,CAAC,QACrB,UACC,MAAM,EAAE,CAAC,SAAS,UACtB,CACF"}
|
package/dist/raw.cjs
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var raw_exports = {};
|
|
20
|
-
__export(raw_exports, {
|
|
21
|
-
guard: () => import_raw.rawGuard,
|
|
22
|
-
literal: () => import_raw.literal,
|
|
23
|
-
materialiser: () => import_inputs.materialiser,
|
|
24
|
-
ref: () => import_raw.ref
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_authoring_raw = require("./authoring/raw.cjs");
|
|
4
|
+
const require_run_inputs = require("./run/inputs.cjs");
|
|
5
|
+
//#region src/raw.ts
|
|
6
|
+
var raw_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
7
|
+
guard: () => require_authoring_raw.rawGuard,
|
|
8
|
+
literal: () => require_authoring_raw.literal,
|
|
9
|
+
materialiser: () => require_run_inputs.materialiser,
|
|
10
|
+
ref: () => require_authoring_raw.ref
|
|
25
11
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.guard = require_authoring_raw.rawGuard;
|
|
14
|
+
exports.literal = require_authoring_raw.literal;
|
|
15
|
+
exports.materialiser = require_run_inputs.materialiser;
|
|
16
|
+
Object.defineProperty(exports, "raw_exports", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function() {
|
|
19
|
+
return raw_exports;
|
|
20
|
+
}
|
|
35
21
|
});
|
|
22
|
+
exports.ref = require_authoring_raw.ref;
|
|
23
|
+
|
|
36
24
|
//# sourceMappingURL=raw.cjs.map
|
package/dist/raw.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/raw.ts"],"sourcesContent":["/**\n * Low-level escape hatch for constructing flow nodes and guards without the\n * typed builder API. Use these when working with operation kinds not covered\n * by the generated methods, or when you need full control over the JSON shape.\n *\n * For most use cases, prefer the generated operation methods on {@link FlowBuilder}\n * (e.g. `builder.lifi.swap(...)`) and the typed guard/materialiser helpers.\n */\nexport { rawGuard as guard, literal, ref } from './authoring/raw.js';\nexport { materialiser } from './run/inputs.js';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"raw.cjs","names":[],"sources":["../src/raw.ts"],"sourcesContent":["/**\n * Low-level escape hatch for constructing flow nodes and guards without the\n * typed builder API. Use these when working with operation kinds not covered\n * by the generated methods, or when you need full control over the JSON shape.\n *\n * For most use cases, prefer the generated operation methods on {@link FlowBuilder}\n * (e.g. `builder.lifi.swap(...)`) and the typed guard/materialiser helpers.\n */\nexport { rawGuard as guard, literal, ref } from './authoring/raw.js';\nexport { materialiser } from './run/inputs.js';\n"],"mappings":""}
|
package/dist/raw.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { literal, rawGuard, ref } from "./authoring/raw.cjs";
|
|
2
|
+
import { materialiser } from "./run/inputs.cjs";
|
|
3
|
+
declare namespace raw_d_exports {
|
|
4
|
+
export { rawGuard as guard, literal, materialiser, ref };
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { rawGuard as guard, literal, materialiser, raw_d_exports, ref };
|
|
8
|
+
//# sourceMappingURL=raw.d.cts.map
|
package/dist/raw.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { literal, rawGuard, ref } from "./authoring/raw.js";
|
|
2
|
+
import { materialiser } from "./run/inputs.js";
|
|
3
|
+
declare namespace raw_d_exports {
|
|
4
|
+
export { rawGuard as guard, literal, materialiser, ref };
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { rawGuard as guard, literal, materialiser, raw_d_exports, ref };
|
|
8
|
+
//# sourceMappingURL=raw.d.ts.map
|
package/dist/raw.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { literal, rawGuard, ref } from "./authoring/raw.js";
|
|
2
3
|
import { materialiser } from "./run/inputs.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
//#region src/raw.ts
|
|
5
|
+
var raw_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
guard: () => rawGuard,
|
|
7
|
+
literal: () => literal,
|
|
8
|
+
materialiser: () => materialiser,
|
|
9
|
+
ref: () => ref
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { rawGuard as guard, literal, materialiser, raw_exports, ref };
|
|
13
|
+
|
|
9
14
|
//# sourceMappingURL=raw.js.map
|
package/dist/raw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/raw.ts"],"sourcesContent":["/**\n * Low-level escape hatch for constructing flow nodes and guards without the\n * typed builder API. Use these when working with operation kinds not covered\n * by the generated methods, or when you need full control over the JSON shape.\n *\n * For most use cases, prefer the generated operation methods on {@link FlowBuilder}\n * (e.g. `builder.lifi.swap(...)`) and the typed guard/materialiser helpers.\n */\nexport { rawGuard as guard, literal, ref } from './authoring/raw.js';\nexport { materialiser } from './run/inputs.js';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"raw.js","names":[],"sources":["../src/raw.ts"],"sourcesContent":["/**\n * Low-level escape hatch for constructing flow nodes and guards without the\n * typed builder API. Use these when working with operation kinds not covered\n * by the generated methods, or when you need full control over the JSON shape.\n *\n * For most use cases, prefer the generated operation methods on {@link FlowBuilder}\n * (e.g. `builder.lifi.swap(...)`) and the typed guard/materialiser helpers.\n */\nexport { rawGuard as guard, literal, ref } from './authoring/raw.js';\nexport { materialiser } from './run/inputs.js';\n"],"mappings":""}
|
package/dist/reachability.cjs
CHANGED
|
@@ -1,123 +1,93 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var reachability_exports = {};
|
|
20
|
-
__export(reachability_exports, {
|
|
21
|
-
buildReachability: () => buildReachability
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(reachability_exports);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/reachability.ts
|
|
24
3
|
const DEFAULT_MAX_HOPS = 2;
|
|
25
4
|
const tokenKey = (token) => `${token.chainId}:${token.address.toLowerCase()}`;
|
|
26
5
|
const isSync = (edge) => edge.availability === void 0;
|
|
27
6
|
const isProxyHeld = (edge) => isSync(edge) && edge.recipient !== "required";
|
|
28
|
-
const visitEdge = ({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (isTerminal(edge) && !found.has(key)) {
|
|
40
|
-
found.set(key, { in: from, out: edge.out, hops: depth });
|
|
41
|
-
}
|
|
42
|
-
if (!isProxyHeld(edge) || expanded.has(key)) return void 0;
|
|
43
|
-
expanded.add(key);
|
|
44
|
-
return edge.out;
|
|
7
|
+
const visitEdge = ({ edge, from, depth, sourceKey, isTerminal, found, expanded }) => {
|
|
8
|
+
const key = tokenKey(edge.out);
|
|
9
|
+
if (key === sourceKey) return void 0;
|
|
10
|
+
if (isTerminal(edge) && !found.has(key)) found.set(key, {
|
|
11
|
+
in: from,
|
|
12
|
+
out: edge.out,
|
|
13
|
+
hops: depth
|
|
14
|
+
});
|
|
15
|
+
if (!isProxyHeld(edge) || expanded.has(key)) return void 0;
|
|
16
|
+
expanded.add(key);
|
|
17
|
+
return edge.out;
|
|
45
18
|
};
|
|
46
|
-
const closureFrom = ({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
if (out) next.push(out);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
frontier = next;
|
|
73
|
-
}
|
|
74
|
-
return found;
|
|
19
|
+
const closureFrom = ({ byIn, from, maxHops, isTerminal }) => {
|
|
20
|
+
const sourceKey = tokenKey(from);
|
|
21
|
+
const found = /* @__PURE__ */ new Map();
|
|
22
|
+
const expanded = /* @__PURE__ */ new Set([sourceKey]);
|
|
23
|
+
let frontier = [from];
|
|
24
|
+
for (let depth = 1; depth <= maxHops && frontier.length > 0; depth++) {
|
|
25
|
+
const next = [];
|
|
26
|
+
for (const node of frontier) for (const edge of byIn.get(tokenKey(node)) ?? []) {
|
|
27
|
+
const out = visitEdge({
|
|
28
|
+
edge,
|
|
29
|
+
from,
|
|
30
|
+
depth,
|
|
31
|
+
sourceKey,
|
|
32
|
+
isTerminal,
|
|
33
|
+
found,
|
|
34
|
+
expanded
|
|
35
|
+
});
|
|
36
|
+
if (out) next.push(out);
|
|
37
|
+
}
|
|
38
|
+
frontier = next;
|
|
39
|
+
}
|
|
40
|
+
return found;
|
|
75
41
|
};
|
|
76
42
|
const indexByIn = (packs) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
return byIn;
|
|
43
|
+
const byIn = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const pack of packs) for (const edge of pack.edges) {
|
|
45
|
+
const key = tokenKey(edge.in);
|
|
46
|
+
const list = byIn.get(key);
|
|
47
|
+
if (list) list.push(edge);
|
|
48
|
+
else byIn.set(key, [edge]);
|
|
49
|
+
}
|
|
50
|
+
return byIn;
|
|
87
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Builds a reachability index over the packs returned by
|
|
54
|
+
* {@link ComposeClient.getZapPacks}. Per-source closures are computed on
|
|
55
|
+
* first use and memoised, so `canRoute` on a handful of pairs stays cheap
|
|
56
|
+
* while `pairs()` enumerates everything.
|
|
57
|
+
*/
|
|
88
58
|
const buildReachability = (packs, options = {}) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
59
|
+
const maxHops = options.maxHops ?? DEFAULT_MAX_HOPS;
|
|
60
|
+
const allowAsync = options.allowAsyncRoutes ?? false;
|
|
61
|
+
const isTerminal = (edge) => isSync(edge) || allowAsync && edge.availability === "future";
|
|
62
|
+
const byIn = indexByIn(packs);
|
|
63
|
+
const memo = /* @__PURE__ */ new Map();
|
|
64
|
+
const closure = (from) => {
|
|
65
|
+
const key = tokenKey(from);
|
|
66
|
+
const cached = memo.get(key);
|
|
67
|
+
if (cached) return cached;
|
|
68
|
+
const computed = closureFrom({
|
|
69
|
+
byIn,
|
|
70
|
+
from,
|
|
71
|
+
maxHops,
|
|
72
|
+
isTerminal
|
|
73
|
+
});
|
|
74
|
+
memo.set(key, computed);
|
|
75
|
+
return computed;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
maxHops,
|
|
79
|
+
canRoute: (from, to) => closure(from).has(tokenKey(to)),
|
|
80
|
+
routableFrom: (from) => [...closure(from).values()],
|
|
81
|
+
pairs: () => {
|
|
82
|
+
const sources = /* @__PURE__ */ new Map();
|
|
83
|
+
for (const pack of packs) for (const edge of pack.edges) sources.set(tokenKey(edge.in), edge.in);
|
|
84
|
+
const all = [];
|
|
85
|
+
for (const source of sources.values()) all.push(...closure(source).values());
|
|
86
|
+
return all;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
118
89
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
});
|
|
90
|
+
//#endregion
|
|
91
|
+
exports.buildReachability = buildReachability;
|
|
92
|
+
|
|
123
93
|
//# sourceMappingURL=reachability.cjs.map
|