import type { HexString } from '../types/index.js'; import type { Callback } from '../utils/scriptHash.js'; import { type PolicyEntryInput } from '../utils/workflowExecute.js'; import { Entity } from './Entity.js'; import type { PoolNetwork } from './PoolNetwork.js'; export declare class OnchainPM extends Entity { network: PoolNetwork; /** Deployed contract address on this chain. */ address: HexString; /** Current policy root for the given strategist. `bytes32(0)` means no policy is set. */ policy(strategist: HexString): import("../index.js").Query<`0x${string}`>; /** * Whether this OnchainPM is fully authorized to run workflows for the pool — * i.e. it is both a balance sheet manager and a minter on the pool's * accounting token. `authorizeOnchainPM` grants both; surface this so the UI * can detect a partial/stale state and re-authorize. */ isAuthorized(): import("../index.js").Query; /** * Executes a whitelisted weiroll script on-chain. * * Build the arguments with: * - `buildScript()` → `{ commands, state, stateBitmap }` * - `fillRuntimeSlots()` → final `state` with runtime values filled in * - `generateExecuteProof()` → `proof` * * @example * ```typescript * const { commands, state: rawState, stateBitmap } = buildScript(workflow, { poolContext, configurableValues }) * const state = fillRuntimeSlots(rawState, workflow, { amount: '0x...' }) * const proof = await generateExecuteProof(computeScriptHash(commands, rawState, stateBitmap, []), allGroupScriptHashes) * await onchainPM.execute({ commands, state, stateBitmap, callbacks: [], proof }) * ``` */ execute(params: { commands: HexString[]; state: HexString[]; stateBitmap: bigint; callbacks: Callback[]; proof: HexString[]; }, options?: { simulate?: boolean; value?: bigint; }): import("../types/transaction.js").Transaction; /** * Runs several whitelisted weiroll scripts in a single transaction via the * OnchainPM's `multicall` — used to batch a strategist's "account"/accounting * workflows (e.g. price updates) into one atomic accounting update. Each item is * built exactly like {@link execute}'s argument; the items are ABI-encoded as * `execute(...)` calls and batched, so they all succeed or revert together. * `value` is the total native value forwarded to the multicall (sum of the * individual workflows' values). * * @example * ```typescript * await onchainPM.executeAccountingBatch([ * { commands, state, stateBitmap, callbacks: [], proof }, * { commands: c2, state: s2, stateBitmap: b2, callbacks: [], proof: p2 }, * ]) * ``` */ executeRawBatch(items: { commands: HexString[]; state: HexString[]; stateBitmap: bigint; callbacks: Callback[]; proof: HexString[]; }[], options?: { simulate?: boolean; value?: bigint; }): import("../types/transaction.js").Transaction; /** * Build and run several whitelisted workflows in one atomic `multicall` — the accounting * update. The SDK builds each `run` entry's script/proof from `policy` (the strategist's * full whitelisted set on this chain, which defines the Merkle proof tree), derives the * pool escrow, and sums the native value. Permission preflights are the caller's concern; * a reverted workflow surfaces via `simulate`. */ executeAccountingBatch(input: { policy: PolicyEntryInput[]; run: number[]; runtimeValues?: Record>; strategist: HexString; scId?: HexString; }, options?: { simulate?: boolean; }): import("../types/transaction.js").Transaction; /** * Build and run a single whitelisted workflow. `policy` is the strategist's full * whitelisted set on this chain (needed for the proof tree); `run` indexes the entry to * execute. `runtimeValues` are the strategist's per-execution inputs (encoded). */ executeWorkflow(input: { policy: PolicyEntryInput[]; run: number; runtimeValues?: Record; strategist: HexString; scId?: HexString; }, options?: { simulate?: boolean; }): import("../types/transaction.js").Transaction; /** * Submits a Hub.updateContract() transaction to update this OnchainPM's * policy root for a strategist. Called whenever workflows are added to or * removed from a group. * * Rebuilds the Merkle root from `scriptHashes` and routes the update: * Hub → Spoke contractUpdater → OnchainPM.trustedCall() * * Pass `scriptHashes: []` to set root to bytes32(0), which disables the strategist. * * The transaction is signed on the hub chain (pool.centrifugeId). */ updatePolicy(params: { scId: HexString; strategist: HexString; /** The whitelisted set. The Merkle leaves are computed from this when `scriptHashes` is omitted. */ policy?: PolicyEntryInput[]; /** Pre-computed leaves. Pass `[]` to disable the strategist. Takes precedence over `policy`. */ scriptHashes?: HexString[]; refund?: HexString; }): import("../types/transaction.js").Transaction; } export interface PolicyUpdateRequest { /** Hub contract address for the target chain. */ hub: HexString; /** Pool ID (uint64). */ poolId: bigint; /** Share class ID (bytes16). */ scId: HexString; /** Chain centrifuge ID (uint16). */ centrifugeId: number; /** OnchainPM contract address to update. */ onchainPM: HexString; /** Strategist Safe multisig address. */ strategist: HexString; /** * Script hashes — one per whitelisted workflow, computed via * `computeScriptHash(commands, state, stateBitmap, [])`. * * Pass an empty array to disable the strategist (sets root to `bytes32(0)`). */ scriptHashes: HexString[]; /** * Address that receives the cross-chain gas refund. * Defaults to `strategist` when omitted. */ refund?: HexString; } export interface PolicyUpdateResult { /** New Merkle root. `bytes32(0)` means the strategist is disabled. */ root: HexString; /** * ABI-encoded `Hub.updateContract()` calldata. * Set this as the `data` field of a transaction sent to `hub`. */ calldata: HexString; } /** * Builds an unsigned `Hub.updateContract()` call to update an OnchainPM * strategist's policy root. * * The Merkle root is computed over `scriptHashes` using `SimpleMerkleTree` * (order-invariant, compatible with `MerkleProofLib` on-chain). Routing: * * ``` * Hub.updateContract() * → Spoke contractUpdater.trustedCall() * → OnchainPM.trustedCall() * → policy[strategist] = newRoot * ``` * * **Usage** (BE calls this whenever workflows are added to / removed from a group): * * ```typescript * const { root, calldata } = await buildPolicyUpdate({ * hub, poolId, scId, centrifugeId, onchainPM, strategist, * scriptHashes: workflows.map(w => computeScriptHash(w.commands, w.state, w.stateBitmap, [])), * }) * // Return calldata + hub to FE → Hub manager (Safe) signs and executes * ``` */ export declare function buildPolicyUpdate(req: PolicyUpdateRequest): Promise; /** * Generates the Merkle inclusion proof required by `OnchainPM.execute()`. * * Rebuilds the same `SimpleMerkleTree` that `buildPolicyUpdate()` committed * on-chain and returns `tree.getProof(index)` for the given `scriptHash`. * Pass the result as the `proof` argument: * * ```typescript * const proof = await generateExecuteProof(scriptHash, allGroupScriptHashes) * // submit: OnchainPM.execute(commands, filledState, stateBitmap, [], proof) * ``` * * For a group with a single workflow the proof is `[]` — the Merkle root is * the script hash itself, so no siblings are needed. * * @throws if `allScriptHashes` is empty (strategist has no whitelisted workflows) * @throws if `scriptHash` is not present in `allScriptHashes` */ export declare function generateExecuteProof(scriptHash: HexString, allScriptHashes: HexString[]): Promise; //# sourceMappingURL=OnchainPM.d.ts.map