/** * The single entry gate every LIT Action passes through before it touches a * chain (Batch 2, work item B1). * * Two decisions were previously re-implemented, in a different order, in every * action — and the order is the whole security property: * * 1. WHICH RPC endpoint we talk to. `validateEvmRpcForPolicy` must run * BEFORE a provider exists, because a provider is only dangerous once it * is dereferenced: the first `await contract.someView()` on an * attacker-supplied endpoint hands the attacker control of every fact the * action then signs over (pause state, borrower, debt, collateral). An * action that constructed the provider first and validated later — as * `process-payment-validator` did, two dozen lines and one network call * apart — had already lost by the time the check ran. * * 2. WHICH contract addresses those reads go to. * `resolveSecurityCriticalAddresses` replaces the caller's * security-critical addresses with the bundled pins on enforced chains and * throws on a contradicting caller value, so a look-alike PositionManager * cannot report `borrower = attacker`. * * Folding both into one call makes the ordering structural instead of * conventional: an action cannot obtain an `rpcUrl` from here without the * validation having already happened, and it gets the pinned address map in the * same breath. After calling this an action MUST read neither `globalThis` nor * `params` for an RPC URL or a contract address again — the only remaining * reads are of the returned object. * * This invents no policy. The rules, the error messages and the hardhat * pass-through all belong to `chain-policy` and `pinned-addresses`; this module * only fixes the sequence. */ import { ChainPolicy } from "./chain-policy"; import { ResolvedContractAddresses } from "./pinned-addresses"; /** * Where an action is permitted to obtain its EVM RPC URL. * * - `"params-or-lit-node"`: a caller-supplied `rpcUrl` is accepted (after * domain validation) and, when absent, `Lit.Actions.getRpcUrl` supplies the * node's own endpoint. This is the historical behaviour of the actions that * run on the Lit network proper. * - `"params-only"`: `rpcUrl` is a REQUIRED jsParam and its absence throws. * Chipotle has no `Lit.Actions.getRpcUrl`, so an action running there cannot * resolve an endpoint by itself; asking the node would throw a confusing * runtime error instead of naming the missing parameter. * * This is NOT a fallback chain: the Lit node's endpoint is a first-class, * non-caller-controlled source, not a degraded substitute used after something * failed. Nothing here recovers from an error. */ export type RpcSource = "params-or-lit-node" | "params-only"; export interface ActionBootstrapParams { /** * The RAW caller-supplied chain string, passed verbatim to * `Lit.Actions.getRpcUrl`. Deliberately not `policy.chain`: `validateChain` * folds "mainnet" into "ethereum", and the Lit node is asked for the chain * the caller named, exactly as every action asked before. */ chain: string; /** Caller-supplied RPC URL, if any. Validated against the policy's domain allowlist. */ rpcUrl?: unknown; /** * Caller-supplied dRPC key for `rpcUrl`, sent in the `Drpc-Key` header. * Only accepted with a keyless dRPC `rpcUrl` (see `evm-rpc`). */ drpcKey?: unknown; /** Caller-supplied address map. Security-critical keys are overwritten by the pins. */ contractAddresses?: Record | undefined; /** Defaults to `"params-or-lit-node"`. */ rpcSource?: RpcSource; } export interface ActionBootstrapResult { /** A validated endpoint. Safe to construct a provider from — and the ONLY such value. */ rpcUrl: string; /** The validated dRPC key for `rpcUrl`, if one was supplied. Pass it to `evmRpcConnection`. */ drpcKey: string | undefined; /** Security-critical keys pinned on enforced chains; other keys passed through. */ addresses: ResolvedContractAddresses; } /** * Validate the RPC endpoint, then resolve the contract addresses — in that * order, always, for every action. * * Throws (never returns a degraded result) when the RPC URL is missing where it * is required, when its domain is not approved for the chain, when the chain has * no pinned address set, or when a caller-supplied address contradicts a pin. */ export declare function bootstrapAction(policy: ChainPolicy, params: ActionBootstrapParams): Promise; //# sourceMappingURL=action-bootstrap.d.ts.map