@sm-lab/recipes 0.2.0 → 0.3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-request-c0CS5wKu.mjs","names":["makeRewards","makeRewardsTree","REPORT_DATA_PARAMS"],"sources":["../src/recipes/operator-info.ts","../src/recipes/chain.ts","../src/recipes/target-limit.ts","../src/recipes/address-changes.ts","../src/encode.ts","../src/recipes/vetting.ts","../src/recipes/validators.ts","../src/recipes/penalties.ts","../src/recipes/bond.ts","../src/recipes/set-gate.ts","../src/recipes/rewards.ts","../src/cl-mock.ts","../src/recipes/cl-activate.ts","../src/recipes/pause.ts","../src/recipes/exit-request.ts"],"sourcesContent":["import type { Hex } from '@sm-lab/receipts';\nimport { contract, type Ctx } from '../context';\n\n/** Decoded NodeOperator (abitype: uint32/uint8 → number, address → Hex, bool → boolean). */\nexport interface OperatorInfo {\n totalAddedKeys: number;\n totalWithdrawnKeys: number;\n totalDepositedKeys: number;\n totalVettedKeys: number;\n stuckValidatorsCount: number;\n depositableValidatorsCount: number;\n targetLimit: number;\n targetLimitMode: number;\n totalExitedKeys: number;\n enqueuedCount: number;\n managerAddress: Hex;\n proposedManagerAddress: Hex;\n rewardAddress: Hex;\n proposedRewardAddress: Hex;\n extendedManagerPermissions: boolean;\n usedPriorityQueue: boolean;\n}\n\n/** Typed read of a node operator's on-chain record. (Port of `NodeOperators.operatorInfo`.) */\nexport async function operatorInfo(ctx: Ctx, opts: { noId: bigint }): Promise<OperatorInfo> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n return op as OperatorInfo;\n}\n","import type { Hex } from '@sm-lab/receipts';\nimport type { Ctx } from '../context';\n\n/** Advance fork time by `seconds` and mine a block (evm_increaseTime + evm_mine). */\nexport async function warpBy(ctx: Ctx, seconds: number | bigint): Promise<void> {\n await ctx.client.increaseTime({ seconds: Number(seconds) });\n await ctx.client.mine({ blocks: 1 });\n}\n\n/**\n * Warp fork time to an absolute unix timestamp and mine a block\n * (evm_setNextBlockTimestamp + evm_mine). The absolute counterpart of `warpBy` — used by\n * `submitRewards`'s consensus-frame wait. Over RPC, `setNextBlockTimestamp` + `mine` reproduces\n * Foundry's `vm.warp(ts)` (the post-warp `block.timestamp` settles automatically after mining).\n */\nexport async function warpTo(ctx: Ctx, timestamp: number | bigint): Promise<void> {\n await ctx.client.setNextBlockTimestamp({ timestamp: BigInt(timestamp) });\n await ctx.client.mine({ blocks: 1 });\n}\n\n/** Take an anvil state snapshot; returns the snapshot id (evm_snapshot). */\nexport function snapshot(ctx: Ctx): Promise<Hex> {\n return ctx.client.snapshot();\n}\n\n/** Revert the fork to a snapshot id (evm_revert). */\nexport async function revert(ctx: Ctx, id: Hex): Promise<void> {\n await ctx.client.revert({ id });\n}\n\n/**\n * Fund an account on the fork by setting its balance (anvil_setBalance). `amountWei` defaults to\n * 100 ETH. Port of `NodeOperators` `topup`.\n */\nexport async function topUpAccount(\n ctx: Ctx,\n opts: { address: Hex; amountWei?: bigint },\n): Promise<{ address: Hex; amountWei: bigint }> {\n const amountWei = opts.amountWei ?? 100n * 10n ** 18n;\n await ctx.client.setBalance({ address: opts.address, value: amountWei });\n return { address: opts.address, amountWei };\n}\n","import { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\n\nexport interface SetTargetLimitOptions {\n noId: bigint;\n /** 0 = off, 1 = soft, 2 = forced. */\n mode: number;\n /** Target validator limit; ignored (forced to 0) when mode === 0. Defaults to 0. */\n limit?: bigint;\n}\n\nexport interface SetTargetLimitResult {\n noId: bigint;\n mode: number;\n limit: bigint;\n}\n\n/**\n * Set an operator's target validator limit (StakingRouter-gated). Port of\n * `NodeOperators.targetLimit` → `updateTargetValidatorsLimits(noId, mode, limit)`.\n */\nexport async function setTargetLimit(\n ctx: Ctx,\n opts: SetTargetLimitOptions,\n): Promise<SetTargetLimitResult> {\n if (opts.mode !== 0 && opts.mode !== 1 && opts.mode !== 2) {\n throw new Error(`@sm-lab/recipes: target limit mode must be 0, 1, or 2 (got ${opts.mode})`);\n }\n const limit = opts.mode === 0 ? 0n : (opts.limit ?? 0n);\n const m = contract(ctx, 'module');\n await actAs(ctx, ctx.addresses.stakingRouter, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'updateTargetValidatorsLimits',\n args: [opts.noId, BigInt(opts.mode), limit],\n account: from,\n chain: null,\n }),\n );\n return { noId: opts.noId, mode: opts.mode, limit };\n}\n","import type { Hex } from '@sm-lab/receipts';\nimport { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\n\n/** Propose a new manager address for an operator (signed by the current manager). */\nexport async function proposeManager(\n ctx: Ctx,\n opts: { noId: bigint; proposed: Hex },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.managerAddress, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'proposeNodeOperatorManagerAddressChange',\n args: [opts.noId, opts.proposed],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Confirm the proposed manager address (signed by the proposed manager). */\nexport async function confirmManager(ctx: Ctx, opts: { noId: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.proposedManagerAddress, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'confirmNodeOperatorManagerAddressChange',\n args: [opts.noId],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Propose a new reward address (signed by the MANAGER, per the on-chain access rule). */\nexport async function proposeReward(\n ctx: Ctx,\n opts: { noId: bigint; proposed: Hex },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.managerAddress, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'proposeNodeOperatorRewardAddressChange',\n args: [opts.noId, opts.proposed],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Confirm the proposed reward address (signed by the proposed reward address). */\nexport async function confirmReward(ctx: Ctx, opts: { noId: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.proposedRewardAddress, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'confirmNodeOperatorRewardAddressChange',\n args: [opts.noId],\n account: from,\n chain: null,\n }),\n );\n}\n","import { toHex } from 'viem';\nimport type { Hex } from '@sm-lab/receipts';\n\n/** A node-operator id packed as the on-chain `bytes8(uint64)` (big-endian). */\nexport function nodeOperatorIdBytes(noId: bigint): Hex {\n return toHex(noId, { size: 8 });\n}\n\n/** A key count packed as the on-chain `bytes16(uint128)` (big-endian). */\nexport function keyCountBytes(count: bigint): Hex {\n return toHex(count, { size: 16 });\n}\n","import type { Hex } from '@sm-lab/receipts';\nimport { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\nimport { keyCountBytes, nodeOperatorIdBytes } from '../encode';\n\n/** Set an operator's vetted-keys count (StakingRouter-gated). `vettedKeys` is the new absolute count. */\nexport async function unvet(ctx: Ctx, opts: { noId: bigint; vettedKeys: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n await actAs(ctx, ctx.addresses.stakingRouter, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'decreaseVettedSigningKeysCount',\n args: [nodeOperatorIdBytes(opts.noId), keyCountBytes(opts.vettedKeys)],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Set an operator's exited-keys count (StakingRouter-gated). `exitedKeys` is the new absolute total. */\nexport async function exit(ctx: Ctx, opts: { noId: bigint; exitedKeys: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n await actAs(ctx, ctx.addresses.stakingRouter, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'updateExitedValidatorsCount',\n args: [nodeOperatorIdBytes(opts.noId), keyCountBytes(opts.exitedKeys)],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Remove `count` keys (default 1) from operator `noId` starting at `keyIndex`, as the operator's manager. */\nexport async function removeKey(\n ctx: Ctx,\n opts: { noId: bigint; keyIndex: bigint; count?: bigint },\n): Promise<{ noId: bigint; keyIndex: bigint; count: bigint }> {\n const count = opts.count ?? 1n;\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n const manager = (op as { managerAddress: Hex }).managerAddress;\n await actAs(ctx, manager, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'removeKeys',\n args: [opts.noId, opts.keyIndex, count],\n account: from,\n chain: null,\n }),\n );\n return { noId: opts.noId, keyIndex: opts.keyIndex, count };\n}\n","import { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\n\n/** One withdrawn-validator record for `reportRegularWithdrawnValidators`. */\nexport interface WithdrawnValidatorInfo {\n nodeOperatorId: bigint;\n keyIndex: bigint;\n exitBalance: bigint;\n slashingPenalty: bigint;\n isSlashed: boolean;\n}\n\n/** Report a validator slashing for an operator's key (Verifier-gated). `keyIndex` is the storage index. */\nexport async function slash(ctx: Ctx, opts: { noId: bigint; keyIndex: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n await actAs(ctx, ctx.addresses.Verifier, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'reportValidatorSlashing',\n args: [opts.noId, opts.keyIndex],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Report a regular validator withdrawal for one key (Verifier-gated). isSlashed = slashingPenalty > 0. */\nexport async function withdraw(\n ctx: Ctx,\n opts: { noId: bigint; keyIndex: bigint; exitBalance: bigint; slashingPenalty?: bigint },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const slashingPenalty = opts.slashingPenalty ?? 0n;\n const info: WithdrawnValidatorInfo = {\n nodeOperatorId: opts.noId,\n keyIndex: opts.keyIndex,\n exitBalance: opts.exitBalance,\n slashingPenalty,\n isSlashed: slashingPenalty > 0n,\n };\n await actAs(ctx, ctx.addresses.Verifier, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'reportRegularWithdrawnValidators',\n args: [[info]],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Effective balance the source reports to mark a key active: 32 ETH + 1 gwei. */\nconst ACTIVE_BALANCE = 32n * 10n ** 18n + 10n ** 9n;\n\n/**\n * Activate `count` deposited-but-not-yet-active keys of an operator (Verifier-gated) by reporting\n * an effective balance of 32 ETH + 1 gwei on each. Skips keys that already have a confirmed\n * balance or are withdrawn. Port of `NodeOperators.activateKeys`. Returns the count activated.\n */\nexport async function activateKeys(\n ctx: Ctx,\n opts: { noId: bigint; count: number },\n): Promise<{ activated: number }> {\n const m = contract(ctx, 'module');\n const { noId, count } = opts;\n\n const op = await ctx.client.readContract({ ...m, functionName: 'getNodeOperator', args: [noId] });\n const total = (op as { totalDepositedKeys: number }).totalDepositedKeys;\n\n // Read each deposited key's confirmed balance + withdrawn flag up front (order-independent).\n const state = await Promise.all(\n Array.from({ length: total }, (_, i) => i).map(async (i) => ({\n i,\n confirmed: (await ctx.client.readContract({\n ...m,\n functionName: 'getKeyConfirmedBalances',\n args: [noId, BigInt(i), 1n],\n })) as readonly bigint[],\n withdrawn: (await ctx.client.readContract({\n ...m,\n functionName: 'isValidatorWithdrawn',\n args: [noId, BigInt(i)],\n })) as boolean,\n })),\n );\n\n // Eligible = confirmed balance 0 and not withdrawn; take the first `count` in index order.\n const eligible = state.filter((s) => s.confirmed[0] === 0n && !s.withdrawn).slice(0, count);\n if (eligible.length < count) {\n throw new Error(\n `@sm-lab/recipes: operator ${noId} has only ${eligible.length} activatable key(s), need ${count}`,\n );\n }\n\n await actAs(ctx, ctx.addresses.Verifier, async (from) => {\n for (const { i } of eligible) {\n // eslint-disable-next-line no-await-in-loop -- impersonation is global fork state; sequential writes\n await ctx.client.writeContract({\n ...m,\n functionName: 'reportValidatorBalance',\n args: [noId, BigInt(i), ACTIVE_BALANCE],\n account: from,\n chain: null,\n });\n }\n });\n\n return { activated: eligible.length };\n}\n\n/**\n * Report an arbitrary CL balance (wei) for one deposited key (Verifier-gated). Validates the key\n * index is in range and not withdrawn. Port of `NodeOperators.reportBalance`.\n */\nexport async function reportBalance(\n ctx: Ctx,\n opts: { noId: bigint; keyIndex: bigint; balanceWei: bigint },\n): Promise<{ noId: bigint; keyIndex: bigint; balanceWei: bigint }> {\n const m = contract(ctx, 'module');\n const { noId, keyIndex, balanceWei } = opts;\n\n const op = await ctx.client.readContract({ ...m, functionName: 'getNodeOperator', args: [noId] });\n const total = (op as { totalDepositedKeys: number }).totalDepositedKeys;\n if (keyIndex >= BigInt(total)) {\n throw new Error(\n `@sm-lab/recipes: key index ${keyIndex} out of bounds (operator ${noId} has ${total} deposited keys)`,\n );\n }\n const withdrawn = await ctx.client.readContract({\n ...m,\n functionName: 'isValidatorWithdrawn',\n args: [noId, keyIndex],\n });\n if (withdrawn) {\n throw new Error(`@sm-lab/recipes: key ${keyIndex} of operator ${noId} is withdrawn`);\n }\n\n await actAs(ctx, ctx.addresses.Verifier, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'reportValidatorBalance',\n args: [noId, keyIndex, balanceWei],\n account: from,\n chain: null,\n }),\n );\n\n return { noId, keyIndex, balanceWei };\n}\n","import { maxUint256, toHex } from 'viem';\nimport type { Hex } from '@sm-lab/receipts';\nimport { actAs, roleMember } from '../act-as';\nimport { contract, type Ctx } from '../context';\nimport { REPORT_GENERAL_DELAYED_PENALTY_ROLE, SETTLE_GENERAL_DELAYED_PENALTY_ROLE } from '../roles';\n\n/** Report a general delayed penalty against an operator (penalty-reporter role). */\nexport async function reportPenalty(\n ctx: Ctx,\n opts: { noId: bigint; amount: bigint; penaltyType?: Hex; details?: string },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const reporter = await roleMember(ctx, m, REPORT_GENERAL_DELAYED_PENALTY_ROLE);\n const penaltyType = opts.penaltyType ?? toHex(1n, { size: 32 });\n const details = opts.details ?? 'fork-penalty';\n await actAs(ctx, reporter, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'reportGeneralDelayedPenalty',\n args: [opts.noId, penaltyType, opts.amount, details],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Cancel a previously-reported general delayed penalty (penalty-reporter role). */\nexport async function cancelPenalty(\n ctx: Ctx,\n opts: { noId: bigint; amount: bigint },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const reporter = await roleMember(ctx, m, REPORT_GENERAL_DELAYED_PENALTY_ROLE);\n await actAs(ctx, reporter, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'cancelGeneralDelayedPenalty',\n args: [opts.noId, opts.amount],\n account: from,\n chain: null,\n }),\n );\n}\n\n/**\n * Settle (process) an operator's general delayed penalty (penalty-settler role).\n * The `maxAmount` option is the per-operator settlement cap passed as the contract's 2nd array arg (confusingly named `bondLockNonces` in the ABI); the default `maxUint256` settles the penalty fully.\n */\nexport async function settlePenalty(\n ctx: Ctx,\n opts: { noId: bigint; maxAmount?: bigint },\n): Promise<void> {\n const m = contract(ctx, 'module');\n const settler = await roleMember(ctx, m, SETTLE_GENERAL_DELAYED_PENALTY_ROLE);\n await actAs(ctx, settler, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'settleGeneralDelayedPenalty',\n args: [[opts.noId], [opts.maxAmount ?? maxUint256]],\n account: from,\n chain: null,\n }),\n );\n}\n\n/** Compensate (pay off) an operator's general delayed penalty — signed by the operator manager. */\nexport async function compensatePenalty(ctx: Ctx, opts: { noId: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.managerAddress, (from) =>\n ctx.client.writeContract({\n ...m,\n functionName: 'compensateGeneralDelayedPenalty',\n args: [opts.noId],\n account: from,\n chain: null,\n }),\n );\n}\n","import { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\n\n/** Top up an operator's bond with ETH (permissionless `depositETH`), signed by the manager. */\nexport async function addBond(ctx: Ctx, opts: { noId: bigint; amount: bigint }): Promise<void> {\n const m = contract(ctx, 'module');\n const acc = contract(ctx, 'Accounting');\n const op = await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperator',\n args: [opts.noId],\n });\n await actAs(ctx, op.managerAddress, (from) =>\n ctx.client.writeContract({\n ...acc,\n functionName: 'depositETH',\n args: [opts.noId],\n account: from,\n value: opts.amount,\n chain: null,\n }),\n );\n}\n\n/**\n * Charge a penalty against an operator's bond (creating bond debt if uncovered). `Accounting.penalize`\n * is module-only, so we impersonate the module address. Returns whether the penalty was fully covered.\n */\nexport async function createBondDebt(\n ctx: Ctx,\n opts: { noId: bigint; amount: bigint },\n): Promise<{ penaltyCovered: boolean }> {\n const moduleAddress = contract(ctx, 'module').address;\n const acc = contract(ctx, 'Accounting');\n return actAs(ctx, moduleAddress, async (from) => {\n const { result, request } = await ctx.client.simulateContract({\n ...acc,\n functionName: 'penalize',\n args: [opts.noId, opts.amount],\n account: from,\n });\n await ctx.client.writeContract({ ...request, chain: null });\n return { penaltyCovered: result };\n });\n}\n","import {\n buildAddressesTree,\n ipfsOptionsFromEnv,\n pinJsonToIpfs,\n shouldAttemptPin,\n} from '@sm-lab/merkle';\nimport { curatedGateAbi, vettedGateAbi } from '@sm-lab/receipts';\nimport type { Hex } from '@sm-lab/receipts';\nimport { actAs, roleMember } from '../act-as';\nimport { resolveGate, type Ctx, type GateSelector } from '../context';\nimport { DEFAULT_ADMIN_ROLE, SET_TREE_ROLE } from '../roles';\n\nexport interface SetGateAddrsOptions {\n /** Whitelisted addresses to encode into the gate's merkle tree. */\n addresses: Hex[];\n /**\n * Gate selector passed to resolveGate. csm: 'ics' (default) | 'idvtc'; cm:\n * 'po'|'pto'|'pgo'|'do'|'eeo'|'iodc'|'iodcp' (default 'po') or a gate index; any: a raw 0x… address.\n */\n selector?: GateSelector | string;\n /** Skip IPFS pinning by supplying a precomputed cid (hermetic tests do this). */\n cid?: string;\n}\n\nexport interface SetGateAddrsResult {\n treeRoot: Hex;\n treeCid: string;\n}\n\n/** Default gate selector per module: cm → 'po' (CuratedGatePO); csm → 'ics' (IcsGate). */\nfunction defaultSelector(ctx: Ctx): string {\n return ctx.module === 'cm' ? 'po' : 'ics';\n}\n\n/**\n * Build a gate addresses tree (OZ ['address'], via @sm-lab/merkle) and install it on the gate\n * (`setTreeParams(root, cid)`), impersonating the gate admin. The cid is pinned to IPFS\n * (env-configured: a local @sm-lab/ipfs or Pinata) unless `cid` is supplied.\n *\n * Module-agnostic (port of fork.just `set-gate-addrs` + `update-gate-tree`, both selector-driven):\n * the csm VettedGate and cm CuratedGate share a byte-identical grantRole/setTreeParams/getRoleMember\n * surface, so the only per-module differences are the resolved address, the default selector, and\n * which gate ABI carries the fragments.\n */\nexport async function setGateAddrs(\n ctx: Ctx,\n opts: SetGateAddrsOptions,\n): Promise<SetGateAddrsResult> {\n const selector = opts.selector ?? defaultSelector(ctx);\n // Both gate ABIs carry a byte-identical grantRole/setTreeParams/getRoleMember surface, so we use\n // the module's own ABI at runtime but pin the compile-time type to one constituent (viem can't\n // infer a union abi). Only those three fragments are ever called — sound for either gate.\n const abi = (ctx.module === 'cm' ? curatedGateAbi : vettedGateAbi) as typeof vettedGateAbi;\n const gate = { address: resolveGate(ctx, selector), abi } as const;\n const tree = buildAddressesTree(opts.addresses);\n const treeRoot = tree.root as Hex;\n const treeCid = opts.cid ?? (await pinTree(tree.dump(), selector));\n const admin = await roleMember(ctx, gate, DEFAULT_ADMIN_ROLE);\n\n await actAs(ctx, admin, async (from) => {\n await ctx.client.writeContract({\n ...gate,\n functionName: 'grantRole',\n args: [SET_TREE_ROLE, admin],\n account: from,\n chain: null,\n });\n await ctx.client.writeContract({\n ...gate,\n functionName: 'setTreeParams',\n args: [treeRoot, treeCid],\n account: from,\n chain: null,\n });\n });\n\n return { treeRoot, treeCid };\n}\n\nasync function pinTree(dump: unknown, selector: string): Promise<string> {\n // Guard BEFORE any network call so hermetic tests (no IPFS env) never hit the wire.\n if (!shouldAttemptPin()) {\n throw new Error(\n '@sm-lab/recipes: could not pin the gate tree — set IPFS_API_URL (a local @sm-lab/ipfs) or PINATA_* credentials, or pass opts.cid',\n );\n }\n return pinJsonToIpfs(dump, `gate-${selector}`, ipfsOptionsFromEnv());\n}\n","import { makeRewards as makeRewardsTree, shouldAttemptPin, type TreeDump } from '@sm-lab/merkle';\nimport { encodeAbiParameters, keccak256, parseAbiParameters, parseEther, toBytes } from 'viem';\nimport {\n feeDistributorAbi,\n feeOracleAbi,\n hashConsensusAbi,\n lidoAbi,\n type Hex,\n} from '@sm-lab/receipts';\nimport { actAs } from '../act-as';\nimport { contract, type Ctx } from '../context';\nimport { randomSeed } from '../random';\nimport { operatorInfo } from './operator-info';\nimport { warpTo } from './chain';\n\n/** Reward draw bounds (mirrors `mock-rewards.mjs`): per active key, in wei. */\nconst REWARD_MIN_WEI = 100_000_000_000_000_000n; // 0.1 ETH\nconst REWARD_MAX_WEI = 200_000_000_000_000_000n; // 0.2 ETH\nconst REWARD_SPAN = REWARD_MAX_WEI - REWARD_MIN_WEI; // 1e17\n/** type(uint64).max — padding id for a lone real operator (FeeDistributor non-empty-proof rule). */\nconst PAD_NO_ID = (1n << 64n) - 1n;\n/** Empty-tree sentinel root: 32 zero bytes. */\nconst ZERO_ROOT = `0x${'00'.repeat(32)}` as Hex;\n\nexport interface RewardsReport {\n /** tree.root, or ZERO_ROOT when there are no leaves. */\n treeRoot: Hex;\n /** pinned (or opts.treeCid); '' when treeRoot is zero. */\n treeCid: string;\n /** pinned (or opts.logCid); '' when treeRoot is zero. */\n logCid: string;\n /** Sum of all per-operator distributed rewards this frame. */\n distributed: bigint;\n /** Always 0n in the mock (matches the source). */\n rebate: bigint;\n /** In-memory OZ tree dump (uint256-as-string → JSON-safe) for tests / re-pin. Undefined when empty. */\n treeDump?: TreeDump;\n /** Cumulative leaves AFTER carry-forward + this frame's deltas, EXCLUDING the pad. */\n cumulatives: Map<bigint, bigint>;\n}\n\nexport interface MakeRewardsOptions {\n /** Injectable seed → deterministic per-key reward draw. Omit for fresh randomness. */\n seed?: Hex;\n /** Carry-forward input: the previous cumulative tree as a Map (or [noId, shares][]). */\n previousCumulatives?: Map<bigint, bigint> | [bigint, bigint][];\n /** Hermetic escape hatch: skip pinning the tree, use this cid. */\n treeCid?: string;\n /** Hermetic escape hatch: skip pinning the log, use this cid. */\n logCid?: string;\n /** Injectable clock (unix seconds) for the report log's block_timestamp. Defaults Date.now()/1000. */\n now?: number;\n}\n\n/**\n * Build the cumulative FeeDistributor rewards tree off on-chain operator state and a seeded mock\n * reward per active key, pin the tree + report log to IPFS (guarded), and return a typed in-memory\n * `RewardsReport`. Port of `mock-rewards.mjs` — but the OUTPUT path stays bigint-typed (no bare\n * `JSON.stringify` of bigints), and the per-key draw is fully seeded (no `Math.random`) so tests can\n * pin `treeRoot`/`distributed`.\n *\n * Carry-forward is via `opts.previousCumulatives` only (option (a) of the design). The pure\n * carry-forward logic — carry every prior leaf forward except the pad, then add this frame's deltas —\n * is identical no matter where the prior Map came from, so the fork path chains calls:\n * `makeRewards(ctx, { previousCumulatives: prev.cumulatives })`.\n * TODO(6f?): on-chain `treeRoot()` → `treeCid()` → IPFS fetch of the prior tree as a default source.\n */\nexport async function makeRewards(ctx: Ctx, opts: MakeRewardsOptions = {}): Promise<RewardsReport> {\n // The all-bigint seeded draw deliberately diverges from the source's lossy\n // `BigInt(Math.floor(Math.random() * Number(REWARD_SPAN)))`: we keccak-hash the seed (32-byte\n // random when omitted, via the shared `randomSeed`) so the draw is reproducible and full-precision.\n const seed = opts.seed ?? randomSeed();\n\n const m = contract(ctx, 'module');\n const count = (await ctx.client.readContract({\n ...m,\n functionName: 'getNodeOperatorsCount',\n })) as bigint;\n\n // --- read every operator (parallel; independent reads), then draw seeded rewards per active key.\n // REUSE operatorInfo (typed; uint32 already decodes to `number` — no Number() casts). The draw is\n // keyed on `noId` so it is order-independent; we still walk in ascending noId for stable output. ---\n const ids = Array.from({ length: Number(count) }, (_, i) => BigInt(i));\n const infos = await Promise.all(ids.map((noId) => operatorInfo(ctx, { noId })));\n\n const reportOperators: Record<string, { distributed_rewards: bigint }> = {};\n const frameDeltas = new Map<bigint, bigint>();\n let distributed = 0n;\n\n for (const [i, noId] of ids.entries()) {\n const info = infos[i]!;\n const activeKeys = info.totalDepositedKeys - info.totalWithdrawnKeys;\n if (activeKeys <= 0) continue;\n\n let opDistributed = 0n;\n for (let k = 0; k < activeKeys; k++) {\n opDistributed += REWARD_MIN_WEI + seededUint(seed, `reward:${noId}:${k}`, REWARD_SPAN);\n }\n reportOperators[noId.toString()] = { distributed_rewards: opDistributed };\n frameDeltas.set(noId, opDistributed);\n distributed += opDistributed;\n }\n\n const rebate = 0n;\n\n // --- carry-forward: prior cumulatives (pad excluded) + this frame's deltas ---\n const cumulatives = new Map<bigint, bigint>();\n for (const [noId, shares] of normalizePrevious(opts.previousCumulatives)) {\n if (noId !== PAD_NO_ID) cumulatives.set(noId, shares);\n }\n for (const [noId, delta] of frameDeltas) {\n cumulatives.set(noId, (cumulatives.get(noId) ?? 0n) + delta);\n }\n\n // --- build leaves; pad a lone real operator (FeeDistributor rejects empty proofs) ---\n const leaves = [...cumulatives.entries()].map(\n ([noId, shares]) => [noId, shares] as [bigint, bigint],\n );\n if (leaves.length === 1) leaves.push([PAD_NO_ID, 0n]);\n\n if (leaves.length === 0) {\n // Empty report: no tree, no pin. submitRewards treats ZERO_ROOT as a graceful skip.\n return { treeRoot: ZERO_ROOT, treeCid: '', logCid: '', distributed, rebate, cumulatives };\n }\n\n // Guard before the IPFS pin so hermetic tests with no IPFS env and no escape cids fail loudly\n // instead of hitting the wire. Mirrors `setGateAddrs.pinTree`. Sits AFTER the empty-report return\n // so an empty fork never needs IPFS configured.\n // shouldAttemptPin() is true by default (local-first); it returns false ONLY when\n // IPFS_API_URL points at real Pinata with no credentials. That is the canonical \"not configured\"\n // state tests can set to trigger this guard.\n const needsPin = opts.treeCid === undefined || opts.logCid === undefined;\n if (needsPin && !shouldAttemptPin()) {\n throw new Error(\n '@sm-lab/recipes: could not pin the rewards tree/log — set IPFS_API_URL (a local @sm-lab/ipfs) or PINATA_* credentials, or pass opts.treeCid + opts.logCid',\n );\n }\n\n // The report log (faithful-but-minimal mock shape) — bigints nested in operators[*] are\n // serialized by merkle's makeRewardsTree (bigintReplacer) before pinning.\n const blockTimestamp = opts.now ?? Math.floor(Date.now() / 1000);\n const log = {\n blockstamp: { block_timestamp: blockTimestamp },\n distributable: distributed,\n distributed_rewards: distributed,\n rebate_to_protocol: rebate,\n operators: reportOperators,\n };\n\n // Delegate pin and tree build to merkle's makeRewards. It returns a JSON-safe treeDump\n // (bigint leaf values serialized as decimal strings) — no local tree build needed.\n // When escape-hatch cids are both set, skip upload entirely (noUpload: true).\n // Otherwise let merkle handle the pin — it uses the same shouldAttemptPin() path guarded above.\n let treeRoot: Hex;\n let treeCid: string;\n let logCid: string;\n let treeDump: TreeDump;\n\n if (opts.treeCid !== undefined && opts.logCid !== undefined) {\n // Both escape-hatch cids supplied: still need to build the tree for treeRoot + treeDump.\n const result = await makeRewardsTree(leaves, { noUpload: true });\n treeRoot = result.treeRoot as Hex;\n treeDump = result.treeDump;\n treeCid = opts.treeCid;\n logCid = opts.logCid;\n } else if (opts.treeCid !== undefined) {\n // tree cid supplied, only pin the log\n const result = await makeRewardsTree(leaves, { log, noUpload: false });\n treeRoot = result.treeRoot as Hex;\n treeDump = result.treeDump;\n treeCid = opts.treeCid;\n logCid = result.logCid ?? '';\n } else if (opts.logCid !== undefined) {\n // log cid supplied, only pin the tree\n const result = await makeRewardsTree(leaves, { noUpload: false });\n treeRoot = result.treeRoot as Hex;\n treeDump = result.treeDump;\n treeCid = result.treeCid ?? '';\n logCid = opts.logCid;\n } else {\n // No escape-hatch cids: delegate both to merkle\n const result = await makeRewardsTree(leaves, { log });\n treeRoot = result.treeRoot as Hex;\n treeDump = result.treeDump;\n treeCid = result.treeCid ?? '';\n logCid = result.logCid ?? '';\n }\n\n return { treeRoot, treeCid, logCid, distributed, rebate, treeDump, cumulatives };\n}\n\n/** Deterministic uint in `[0, span)` from `keccak256(toBytes(\\`${seed}:${label}\\`)) % span`. */\nfunction seededUint(seed: Hex, label: string, span: bigint): bigint {\n return BigInt(keccak256(toBytes(`${seed}:${label}`))) % span;\n}\n\n/** Normalize the carry-forward input (Map or entries) to an iterable of [noId, shares]. */\nfunction normalizePrevious(\n prev: MakeRewardsOptions['previousCumulatives'],\n): Iterable<[bigint, bigint]> {\n if (!prev) return [];\n return prev instanceof Map ? prev.entries() : prev;\n}\n\n// --- submitRewards (port of OracleReport.s.sol:submitRewards) -------------------------------------\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as const;\n\n/**\n * The `IFeeOracle.ReportData` struct as ONE tuple parameter — components in declaration order\n * (verified against `fixtures/receipts/src/abi/FeeOracle.ts`). `abi.encode(data)` for a single\n * struct == ABI-encoding one tuple parameter (head/tail offsets for the dynamic `string` fields);\n * passing the tuple type as a single param to `encodeAbiParameters` reproduces it. Do NOT flatten\n * into 9 top-level params — that drops the tuple offset and changes the hash. This is the exact\n * reportHash transcription trap.\n */\nconst REPORT_DATA_PARAMS = parseAbiParameters(\n '(uint256 consensusVersion, uint256 refSlot, bytes32 treeRoot, string treeCid, string logCid, uint256 distributed, uint256 rebate, bytes32 strikesTreeRoot, string strikesTreeCid)',\n);\n\n/** The 9-field oracle ReportData tuple (bigints for the uint256 fields). */\ninterface ReportData {\n consensusVersion: bigint;\n refSlot: bigint;\n treeRoot: Hex;\n treeCid: string;\n logCid: string;\n distributed: bigint;\n rebate: bigint;\n strikesTreeRoot: Hex;\n strikesTreeCid: string;\n}\n\nexport interface SubmitRewardsResult {\n /** false when treeRoot is zero (a legitimate empty-report skip). */\n submitted: boolean;\n /** present when submitted: the consensus frame's refSlot. */\n refSlot?: bigint;\n /** echo of report.treeRoot when submitted. */\n treeRoot?: Hex;\n /** the keccak256(abi.encode(data)) reached consensus on. */\n reportHash?: Hex;\n /** the consensus members that submitted (fast-lane, or the getMembers fallback). */\n members?: Hex[];\n}\n\n/**\n * Submit a `RewardsReport` (from `makeRewards`) on-chain: fund the FeeDistributor, warp to the next\n * consensus frame, build the `ReportData` tuple, reach consensus across the fast-lane members (with\n * a `getMembers` fallback), and submit the report data. Port of `OracleReport.s.sol:submitRewards`.\n *\n * Fork-only in practice (it WRITES + warps); the hermetic tests assert the call sequence, the funding\n * literals, the warp arguments, and the reportHash, not real frame advancement.\n *\n * A zero-root report (no active keys this frame) is a graceful no-op: returns `{ submitted: false }`\n * with no reads/writes, so `submitRewards(ctx, await makeRewards(ctx))` composes on an empty fork.\n */\nexport async function submitRewards(ctx: Ctx, report: RewardsReport): Promise<SubmitRewardsResult> {\n if (report.treeRoot === ZERO_ROOT) return { submitted: false };\n\n const feeDistributor = { address: ctx.addresses.FeeDistributor as Hex, abi: feeDistributorAbi };\n const oracle = { address: ctx.addresses.FeeOracle as Hex, abi: feeOracleAbi };\n const hashConsensus = { address: ctx.addresses.HashConsensus as Hex, abi: hashConsensusAbi };\n const lido = { address: ctx.addresses.lido, abi: lidoAbi };\n\n // --- 1. Fund the FeeDistributor with stETH shares if it cannot cover this frame ---\n const pending = (await ctx.client.readContract({\n ...feeDistributor,\n functionName: 'pendingSharesToDistribute',\n })) as bigint;\n if (pending < report.distributed + report.rebate) {\n const neededShares = report.distributed + report.rebate - pending;\n // X = getPooledEthByShares(neededShares); submit value = X + 1 ether; setBalance = X + 2 ether\n // (matches the source's `neededEth = X + 1 ether; _setBalance(fd, neededEth + 1 ether)`).\n // Inline the impersonation (not actAs) so the funding survives — actAs would clobber the\n // balance back to 100 ETH, which can be < the needed amount for large rewards.\n const x = (await ctx.client.readContract({\n ...lido,\n functionName: 'getPooledEthByShares',\n args: [neededShares],\n })) as bigint;\n const submitValue = x + parseEther('1');\n const fd = feeDistributor.address;\n await ctx.client.setBalance({ address: fd, value: x + parseEther('2') });\n await ctx.client.impersonateAccount({ address: fd });\n try {\n await ctx.client.writeContract({\n ...lido,\n functionName: 'submit',\n args: [ZERO_ADDRESS],\n value: submitValue,\n account: fd,\n chain: null,\n });\n } finally {\n await ctx.client.stopImpersonatingAccount({ address: fd });\n }\n }\n\n // --- 2. Warp to the next valid consensus frame (_waitForNextRefSlot) — all bigint math ---\n const [slotsPerEpoch, secondsPerSlot, genesisTime] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getChainConfig',\n })) as [bigint, bigint, bigint];\n const [initialEpoch, epochsPerFrame] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getFrameConfig',\n })) as [bigint, bigint, bigint];\n\n const ts = (await ctx.client.getBlock()).timestamp;\n const epoch = (ts - genesisTime) / secondsPerSlot / slotsPerEpoch;\n if (epoch < initialEpoch) {\n await warpTo(ctx, genesisTime + 1n + initialEpoch * slotsPerEpoch * secondsPerSlot);\n }\n\n const [frameRefSlot] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getCurrentFrame',\n })) as [bigint, bigint];\n const frameStart =\n genesisTime + (frameRefSlot + slotsPerEpoch * epochsPerFrame + 1n) * secondsPerSlot;\n const ts2 = (await ctx.client.getBlock()).timestamp;\n if (frameStart > ts2) {\n await warpTo(ctx, frameStart);\n }\n\n // Re-read the frame AFTER the warp: the report must carry the now-current refSlot, not the\n // pre-warp one (the warp deliberately advances a full frame past `frameRefSlot`). The source\n // reads getCurrentFrame() again right after `_waitForNextRefSlot()` (OracleReport.s.sol:46);\n // inlining the wait must not drop that second read, or submitReport/submitReportData land on a\n // stale refSlot and HashConsensus reverts.\n const [refSlot] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getCurrentFrame',\n })) as [bigint, bigint];\n\n // --- 3. Build ReportData (mock strikes values) + reportHash ---\n const consensusVersion = (await ctx.client.readContract({\n ...oracle,\n functionName: 'getConsensusVersion',\n })) as bigint;\n const data: ReportData = {\n consensusVersion,\n refSlot,\n treeRoot: report.treeRoot,\n treeCid: report.treeCid,\n logCid: report.logCid,\n distributed: report.distributed,\n rebate: report.rebate,\n strikesTreeRoot: strikesTreeRoot(refSlot),\n strikesTreeCid: `mock-strikes-${refSlot}`,\n };\n const hash = reportHash(data);\n\n // --- 4. Members with fast-lane → getMembers fallback (the Fixtures.sol fallback the .s.sol omits) ---\n let [members] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getFastLaneMembers',\n })) as [Hex[], bigint[]];\n if (members.length === 0) {\n [members] = (await ctx.client.readContract({\n ...hashConsensus,\n functionName: 'getMembers',\n })) as [Hex[], bigint[]];\n }\n if (members.length === 0) {\n throw new Error('@sm-lab/recipes: no consensus members to reach quorum');\n }\n\n // --- 5. Reach consensus from every member, then submit the report data as members[0] ---\n // Sequential is REQUIRED, not a missed parallelization: actAs impersonates one account at a time\n // (impersonate → write → stop), and impersonation is global fork state — running these in parallel\n // would interleave the start/stop of different members. Matches the source's sequential loop.\n for (const member of members) {\n // eslint-disable-next-line no-await-in-loop -- sequential by necessity (impersonation is global state)\n await actAs(ctx, member, (from) =>\n ctx.client.writeContract({\n ...hashConsensus,\n functionName: 'submitReport',\n args: [refSlot, hash, consensusVersion],\n account: from,\n chain: null,\n }),\n );\n }\n\n const contractVersion = (await ctx.client.readContract({\n ...oracle,\n functionName: 'getContractVersion',\n })) as bigint;\n await actAs(ctx, members[0]!, (from) =>\n ctx.client.writeContract({\n ...oracle,\n functionName: 'submitReportData',\n args: [data, contractVersion],\n account: from,\n chain: null,\n }),\n );\n\n return { submitted: true, refSlot, treeRoot: report.treeRoot, reportHash: hash, members };\n}\n\n/** keccak256(abi.encode(data)) — encode the 9-field struct as ONE tuple param (see REPORT_DATA_PARAMS). */\nfunction reportHash(data: ReportData): Hex {\n return keccak256(encodeAbiParameters(REPORT_DATA_PARAMS, [data]));\n}\n\n/**\n * Mock strikes root: `keccak256(abi.encode(\"mock-strikes\", refSlot))` — TWO top-level params\n * (`string`, `uint256`), NOT a tuple. Matches the source's `abi.encode(a, b)`.\n */\nfunction strikesTreeRoot(refSlot: bigint): Hex {\n return keccak256(\n encodeAbiParameters(parseAbiParameters('string, uint256'), ['mock-strikes', refSlot]),\n );\n}\n","/**\n * cl-mock bridge — a thin `fetch` client that POSTs one validator to a running\n * `@sm-lab/cl` (`/admin/validators`). Mirrors the discipline of `tools/merkle/src/ipfs.ts`:\n * trailing-slash-stripped URL join, explicit `as` cast for the response (no DOM lib), and a\n * throw carrying status + the mock's `errors[]`. Ctx-agnostic — takes a `clMockUrl: string`, not\n * the whole `Ctx`, so it stays trivially unit-testable.\n */\n\nimport type { Hex } from '@sm-lab/receipts';\n\nexport interface SetValidatorInput {\n pubkey: Hex;\n /**\n * The CL statuses the recipes bridge sets: `active_ongoing` (clActivate) / `active_exiting`\n * (exitRequest's optional flip). cl-mock's full status union lives in the app, not here.\n */\n status: 'active_ongoing' | 'active_exiting';\n /** Serialized to a gwei integer string on the wire; omitted when undefined. */\n effectiveBalanceGwei?: bigint;\n}\n\ninterface ClMockResponse {\n accepted: number;\n errors: string[];\n}\n\n/**\n * POST one validator to a running `@sm-lab/cl` `/admin/validators`. Surfaces the mock's\n * `errors[]` and throws unless the single item was accepted.\n *\n * cl-mock returns 200 (clean), 207 (partial — only when `errors.length > 0` AND `accepted > 0`,\n * which is impossible for a single item), or 400 (all rejected, no `accepted` field). For one\n * item the realistic failure is 400, caught by the `!res.ok` clause. The `(accepted ?? 0) < 1`\n * guard is defensive belt-and-braces for a synthetic accepted:0 / missing-`accepted` body the mock\n * never actually emits — the `?? 0` is load-bearing, since a bare `accepted < 1` is `false` for\n * `undefined` and would let such a body through as a silent success.\n */\nexport async function setClValidator(clMockUrl: string, input: SetValidatorInput): Promise<void> {\n const url = `${clMockUrl.replace(/\\/+$/, '')}/admin/validators`;\n const body = JSON.stringify({\n pubkey: input.pubkey,\n status: input.status,\n ...(input.effectiveBalanceGwei !== undefined\n ? { effective_balance: input.effectiveBalanceGwei.toString() }\n : {}),\n });\n\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body,\n });\n\n const json = (await res.json().catch(() => undefined)) as ClMockResponse | undefined;\n if (!res.ok || !json || (json.accepted ?? 0) < 1) {\n const errs = json?.errors?.length ? ` — ${json.errors.join('; ')}` : '';\n throw new Error(\n `@sm-lab/recipes: cl-mock rejected validator (${res.status} ${res.statusText})${errs}`,\n );\n }\n}\n","import type { Hex } from '@sm-lab/receipts';\nimport type { Ctx } from '../context';\nimport { setClValidator } from '../cl-mock';\nimport { getKeyBalance, getPubkey } from './reads';\n\nconst GWEI_PER_ETH = 1_000_000_000n;\nconst BASE_ETH_GWEI = 32n * GWEI_PER_ETH; // base 32 ETH, in gwei (32_000_000_000n)\n\nexport interface ClActivateResult {\n pubkey: Hex;\n status: 'active_ongoing';\n effectiveBalanceGwei: bigint;\n}\n\n/**\n * Effective balance of an active validator, in gwei: 32 ETH + the key's on-chain allocated balance\n * (sub-gwei dust floored). Shared by `clActivate` (`active_ongoing`) and `exitRequest`'s optional\n * cl-mock flip (`active_exiting`) so both bridges report the same balance for the same key.\n */\nexport async function activeEffectiveBalanceGwei(\n ctx: Ctx,\n opts: { noId: bigint; keyIndex: bigint },\n): Promise<bigint> {\n const allocWei = await getKeyBalance(ctx, opts);\n // BigInt `/` floors sub-gwei dust (allocWei >= 0 so floor == truncation toward zero).\n return BASE_ETH_GWEI + allocWei / GWEI_PER_ETH;\n}\n\n/**\n * Read a key's pubkey + allocated balance on-chain, then mark it `active_ongoing` on a running\n * cl-mock with effective balance = 32 ETH + allocated balance, in gwei. Port of\n * `cl-mock.just:cl-activate`. Diverges from the Solidity helper's integer-ETH truncation\n * (`balances[0] / 1 ether`) by keeping full gwei precision (cl-mock stores `effective_balance`\n * in gwei) — the spec-blessed divergence.\n */\nexport async function clActivate(\n ctx: Ctx,\n opts: { noId: bigint; keyIndex: bigint },\n): Promise<ClActivateResult> {\n if (!ctx.clMockUrl) {\n throw new Error('@sm-lab/recipes: clActivate needs ctx.clMockUrl (a running cl-mock)');\n }\n // Sequential, not Promise.all: pubkey first so an empty key throws \"no key found\" before any\n // balance read (deterministic errors; no balance read on the empty-pubkey path).\n const pubkey = await getPubkey(ctx, opts);\n const effectiveBalanceGwei = await activeEffectiveBalanceGwei(ctx, opts);\n await setClValidator(ctx.clMockUrl, {\n pubkey,\n status: 'active_ongoing',\n effectiveBalanceGwei,\n });\n return { pubkey, status: 'active_ongoing', effectiveBalanceGwei };\n}\n","import { maxUint256 } from 'viem';\nimport type { Abi } from 'viem';\nimport { curatedGateAbi, vettedGateAbi } from '@sm-lab/receipts';\nimport type { Hex } from '@sm-lab/receipts';\nimport { actAs, roleMember } from '../act-as';\nimport { contract, resolveGate, type Ctx } from '../context';\nimport { DEFAULT_ADMIN_ROLE, PAUSE_ROLE, RESUME_ROLE } from '../roles';\n\nexport interface PauseResult {\n /** the target keyword as supplied (module | accounting | gate selector) */\n target: string;\n /** the resolved contract address */\n address: Hex;\n /** paused state after the call */\n paused: boolean;\n}\n\n/**\n * Resolve a pause target keyword to a contract handle. `module` and `accounting` are reserved;\n * anything else is a gate selector resolved via `resolveGate` (ics/idvtc for csm; po…iodcp/index\n * for cm; 0x… for either).\n */\nfunction resolveTarget(ctx: Ctx, target: string): { address: Hex; abi: Abi } {\n if (target === 'module') {\n const m = contract(ctx, 'module');\n return { address: m.address, abi: m.abi as Abi };\n }\n if (target === 'accounting') {\n const a = contract(ctx, 'Accounting');\n return { address: a.address, abi: a.abi as Abi };\n }\n // All gate types share the PausableUntil surface, so either gate abi decodes it.\n const abi = (ctx.module === 'cm' ? curatedGateAbi : vettedGateAbi) as Abi;\n return { address: resolveGate(ctx, target), abi };\n}\n\n/** Pause a target (module | accounting | gate selector). Idempotent: no-op if already paused. */\nexport async function pause(ctx: Ctx, opts: { target: string }): Promise<PauseResult> {\n const t = resolveTarget(ctx, opts.target);\n const already = (await ctx.client.readContract({ ...t, functionName: 'isPaused' })) as boolean;\n if (already) return { target: opts.target, address: t.address, paused: true };\n\n const admin = await roleMember(ctx, t, DEFAULT_ADMIN_ROLE);\n await actAs(ctx, admin, async (from) => {\n await ctx.client.writeContract({\n ...t,\n functionName: 'grantRole',\n args: [PAUSE_ROLE, admin],\n account: from,\n chain: null,\n });\n await ctx.client.writeContract({\n ...t,\n functionName: 'pauseFor',\n args: [maxUint256],\n account: from,\n chain: null,\n });\n });\n return { target: opts.target, address: t.address, paused: true };\n}\n\n/** Resume a target (module | accounting | gate selector). Idempotent: no-op if not paused. */\nexport async function resume(ctx: Ctx, opts: { target: string }): Promise<PauseResult> {\n const t = resolveTarget(ctx, opts.target);\n const paused = (await ctx.client.readContract({ ...t, functionName: 'isPaused' })) as boolean;\n if (!paused) return { target: opts.target, address: t.address, paused: false };\n\n const admin = await roleMember(ctx, t, DEFAULT_ADMIN_ROLE);\n await actAs(ctx, admin, async (from) => {\n await ctx.client.writeContract({\n ...t,\n functionName: 'grantRole',\n args: [RESUME_ROLE, admin],\n account: from,\n chain: null,\n });\n await ctx.client.writeContract({\n ...t,\n functionName: 'resume',\n account: from,\n chain: null,\n });\n });\n return { target: opts.target, address: t.address, paused: false };\n}\n","import {\n encodeAbiParameters,\n encodePacked,\n keccak256,\n numberToHex,\n parseAbiParameters,\n} from 'viem';\nimport { stakingRouterAbi, vEBOAbi, type Hex } from '@sm-lab/receipts';\nimport { actAs, roleMember } from '../act-as';\nimport { contract, type Ctx } from '../context';\nimport { DEFAULT_ADMIN_ROLE } from '../roles';\nimport { setClValidator } from '../cl-mock';\nimport { activeEffectiveBalanceGwei } from './cl-activate';\n\nexport interface ExitRequestOptions {\n noId: bigint;\n keyIndex: bigint;\n /** CL validator index packed into the report. Defaults to 900000n (matches the just recipe). */\n validatorIndex?: bigint;\n}\n\nexport interface ExitRequestResult {\n noId: bigint;\n keyIndex: bigint;\n validatorIndex: bigint;\n /** module id discovered in the StakingRouter. */\n moduleId: bigint;\n /** the report ref slot (= last consensus report refSlot + 1). */\n refSlot: bigint;\n /** keccak256(abi.encode(report)) submitted to VEBO. */\n reportHash: Hex;\n /** the 48-byte BLS pubkey exited. */\n pubkey: Hex;\n /** present iff ctx.clMockUrl was set: the validator was marked active_exiting on the cl-mock. */\n clStatus?: 'active_exiting';\n}\n\n/** DATA_FORMAT_LIST — the single supported VEBO exit-request data format. */\nconst DATA_FORMAT = 1n;\n/** processing deadline offset — `block.timestamp + 1 days` (matches the source). */\nconst ONE_DAY = 86_400n;\n\n/**\n * The VEBO `ReportData` struct as ONE tuple parameter (components in declaration order, verified\n * against `fixtures/receipts/src/abi/VEBO.ts`). `abi.encode(report)` for a single struct ==\n * ABI-encoding one tuple parameter — do NOT flatten into 5 top-level params (that drops the tuple\n * offset and changes the hash). Same trap `rewards.ts` documents for the fee-oracle report.\n */\nconst REPORT_DATA_PARAMS = parseAbiParameters(\n '(uint256 consensusVersion, uint256 refSlot, uint256 requestsCount, uint256 dataFormat, bytes data)',\n);\n\n/**\n * Request a single validator exit via the Validators Exit Bus Oracle. Port of\n * `NodeOperators.s.sol:_exitRequest`. Reads the key pubkey + discovers the module id, packs the\n * 64-byte exit request, then fakes VEBO consensus by impersonating the consensus contract\n * (`submitConsensusReport`) and submits the data as the VEBO admin (`grantRole` + `submitReportData`).\n *\n * Module-agnostic: `contract(ctx,'module')` picks CSModule/CuratedModule by `ctx.module`, and the\n * module-id scan matches that same address — no csm/cm branching.\n *\n * Optional cl-mock reflection (beyond the source): when `ctx.clMockUrl` is set, the validator is\n * additionally marked `active_exiting` on the running cl-mock (mirroring `clActivate`); skipped\n * silently otherwise.\n *\n * Deliberate divergences from the source (identical on-chain effect):\n * - reuses the VEBO admin as the `submitReportData` submitter (source grants a fresh address);\n * `grantRole` is idempotent so re-granting the admin never reverts.\n * - scans ALL staking-module ids (source's `for (i=len-1; i>0; i--)` skips index 0).\n */\nexport async function exitRequest(ctx: Ctx, opts: ExitRequestOptions): Promise<ExitRequestResult> {\n const validatorIndex = opts.validatorIndex ?? 900_000n;\n const m = contract(ctx, 'module');\n const vebo = { address: ctx.addresses.vebo, abi: vEBOAbi } as const;\n\n // 1. key pubkey (48 bytes) + module id (scan the StakingRouter for this module's address)\n const pubkey = (await ctx.client.readContract({\n ...m,\n functionName: 'getSigningKeys',\n args: [opts.noId, opts.keyIndex, 1n],\n })) as Hex;\n const moduleId = await resolveModuleId(ctx, m.address);\n\n // 2. pack the single exit request: bytes3 moduleId | bytes5 noId | bytes8 validatorIndex | pubkey\n const data = encodePacked(\n ['bytes3', 'bytes5', 'bytes8', 'bytes'],\n [\n numberToHex(moduleId, { size: 3 }),\n numberToHex(opts.noId, { size: 5 }),\n numberToHex(validatorIndex, { size: 8 }),\n pubkey,\n ],\n );\n\n // 3. build the report (refSlot = last consensus report refSlot + 1) + its hash\n const consensusReport = (await ctx.client.readContract({\n ...vebo,\n functionName: 'getConsensusReport',\n })) as readonly [Hex, bigint, bigint, boolean];\n const refSlot = consensusReport[1] + 1n;\n const consensusVersion = (await ctx.client.readContract({\n ...vebo,\n functionName: 'getConsensusVersion',\n })) as bigint;\n const report = {\n consensusVersion,\n refSlot,\n requestsCount: 1n,\n dataFormat: DATA_FORMAT,\n data,\n };\n const reportHash = keccak256(encodeAbiParameters(REPORT_DATA_PARAMS, [report]));\n\n // 4. fake consensus: impersonate the consensus contract and submit the report hash directly\n const consensus = (await ctx.client.readContract({\n ...vebo,\n functionName: 'getConsensusContract',\n })) as Hex;\n const deadline = (await ctx.client.getBlock()).timestamp + ONE_DAY;\n await actAs(ctx, consensus, (from) =>\n ctx.client.writeContract({\n ...vebo,\n functionName: 'submitConsensusReport',\n args: [reportHash, refSlot, deadline],\n account: from,\n chain: null,\n }),\n );\n\n // 5. submit the report data as the VEBO admin (granting itself SUBMIT_DATA_ROLE first)\n const admin = await roleMember(ctx, vebo, DEFAULT_ADMIN_ROLE);\n const submitRole = (await ctx.client.readContract({\n ...vebo,\n functionName: 'SUBMIT_DATA_ROLE',\n })) as Hex;\n const contractVersion = (await ctx.client.readContract({\n ...vebo,\n functionName: 'getContractVersion',\n })) as bigint;\n await actAs(ctx, admin, async (from) => {\n await ctx.client.writeContract({\n ...vebo,\n functionName: 'grantRole',\n args: [submitRole, admin],\n account: from,\n chain: null,\n });\n await ctx.client.writeContract({\n ...vebo,\n functionName: 'submitReportData',\n args: [report, contractVersion],\n account: from,\n chain: null,\n });\n });\n\n // 6. optional cl-mock reflection (opt-in via ctx.clMockUrl), mirroring clActivate. POST\n // /admin/validators REPLACES the entry, so carry the effective balance (32 ETH + allocated) — a\n // status-only flip would wipe the balance clActivate set. Skipped (not thrown) when clMockUrl is\n // unset: the on-chain VEBO submit above is the primary effect.\n let clStatus: 'active_exiting' | undefined;\n if (ctx.clMockUrl) {\n const effectiveBalanceGwei = await activeEffectiveBalanceGwei(ctx, opts);\n await setClValidator(ctx.clMockUrl, { pubkey, status: 'active_exiting', effectiveBalanceGwei });\n clStatus = 'active_exiting';\n }\n\n return {\n noId: opts.noId,\n keyIndex: opts.keyIndex,\n validatorIndex,\n moduleId,\n refSlot,\n reportHash,\n pubkey,\n clStatus,\n };\n}\n\n/** Find the staking-module id whose registered address is `moduleAddress` (scans ALL ids). */\nasync function resolveModuleId(ctx: Ctx, moduleAddress: Hex): Promise<bigint> {\n const sr = { address: ctx.addresses.stakingRouter, abi: stakingRouterAbi } as const;\n const ids = (await ctx.client.readContract({\n ...sr,\n functionName: 'getStakingModuleIds',\n })) as bigint[];\n const mods = (await Promise.all(\n ids.map((id) =>\n ctx.client.readContract({ ...sr, functionName: 'getStakingModule', args: [id] }),\n ),\n )) as { stakingModuleAddress: Hex }[];\n const idx = mods.findIndex(\n (mod) => mod.stakingModuleAddress.toLowerCase() === moduleAddress.toLowerCase(),\n );\n if (idx === -1)\n throw new Error(`@sm-lab/recipes: module ${moduleAddress} not registered in the StakingRouter`);\n return ids[idx]!;\n}\n"],"mappings":";;;;;;AAwBA,eAAsB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AAW;GAAE;GAAQ,QAAQ;GAAkB;EAAqB,CAAC;EAC9F,WAAW;CACb;CAEA,OAAO;EACL,MAAM,KAAK;EACX,UAAU,KAAK;EACf;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;AAGA,eAAe,gBAAgB,KAAU,eAAqC;CAC5E,MAAM,KAAK;EAAE,SAAS,IAAI,UAAU;EAAe,KAAK;CAAiB;CACzE,MAAM,MAAO,MAAM,IAAI,OAAO,aAAa;EACzC,GAAG;EACH,cAAc;CAChB,CAAC;CAMD,MAAM,OAAM,MALQ,QAAQ,IAC1B,IAAI,KAAK,OACP,IAAI,OAAO,aAAa;EAAE,GAAG;EAAI,cAAc;EAAoB,MAAM,CAAC,EAAE;CAAE,CAAC,CACjF,CACF,EAAA,CACiB,WACd,QAAQ,IAAI,qBAAqB,YAAY,MAAM,cAAc,YAAY,CAChF;CACA,IAAI,QAAQ,IACV,MAAM,IAAI,MAAM,2BAA2B,cAAc,qCAAqC;CAChG,OAAO,IAAI;AACb"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as GateSelector, c as contract, d as makeClient, i as Ctx, l as resolveGate, n as ConnectOptions, o as ResolvedAddresses, r as CsmGateSelector, s as connect, t as CmGateSelector, u as RecipeClient } from "./context-BiYdAnKn.mjs";
1
+ import { a as GateSelector, c as contract, d as makeClient, i as Ctx, l as resolveGate, n as ConnectOptions, o as ResolvedAddresses, r as CsmGateSelector, s as connect, t as CmGateSelector, u as RecipeClient } from "./context-7_EMmCZw.mjs";
2
2
  import { Abi } from "viem";
3
3
  import { Hex } from "@sm-lab/receipts";
4
4
  import { TreeDump } from "@sm-lab/merkle";
@@ -88,6 +88,36 @@ declare function warpTo(ctx: Ctx, timestamp: number | bigint): Promise<void>;
88
88
  declare function snapshot(ctx: Ctx): Promise<Hex>;
89
89
  /** Revert the fork to a snapshot id (evm_revert). */
90
90
  declare function revert(ctx: Ctx, id: Hex): Promise<void>;
91
+ /**
92
+ * Fund an account on the fork by setting its balance (anvil_setBalance). `amountWei` defaults to
93
+ * 100 ETH. Port of `NodeOperators` `topup`.
94
+ */
95
+ declare function topUpAccount(ctx: Ctx, opts: {
96
+ address: Hex;
97
+ amountWei?: bigint;
98
+ }): Promise<{
99
+ address: Hex;
100
+ amountWei: bigint;
101
+ }>;
102
+ //#endregion
103
+ //#region src/recipes/target-limit.d.ts
104
+ interface SetTargetLimitOptions {
105
+ noId: bigint;
106
+ /** 0 = off, 1 = soft, 2 = forced. */
107
+ mode: number;
108
+ /** Target validator limit; ignored (forced to 0) when mode === 0. Defaults to 0. */
109
+ limit?: bigint;
110
+ }
111
+ interface SetTargetLimitResult {
112
+ noId: bigint;
113
+ mode: number;
114
+ limit: bigint;
115
+ }
116
+ /**
117
+ * Set an operator's target validator limit (StakingRouter-gated). Port of
118
+ * `NodeOperators.targetLimit` → `updateTargetValidatorsLimits(noId, mode, limit)`.
119
+ */
120
+ declare function setTargetLimit(ctx: Ctx, opts: SetTargetLimitOptions): Promise<SetTargetLimitResult>;
91
121
  //#endregion
92
122
  //#region src/roles.d.ts
93
123
  /** OZ AccessControl default admin role (all-zero bytes32). */
@@ -96,6 +126,8 @@ declare const DEFAULT_ADMIN_ROLE: Hex;
96
126
  declare const SET_TREE_ROLE: `0x${string}`;
97
127
  /** PausableWithRoles: keccak256("RESUME_ROLE"). */
98
128
  declare const RESUME_ROLE: `0x${string}`;
129
+ /** PausableWithRoles: keccak256("PAUSE_ROLE"). */
130
+ declare const PAUSE_ROLE: `0x${string}`;
99
131
  /** BaseModule: keccak256("REPORT_GENERAL_DELAYED_PENALTY_ROLE"). */
100
132
  declare const REPORT_GENERAL_DELAYED_PENALTY_ROLE: `0x${string}`;
101
133
  /** BaseModule: keccak256("SETTLE_GENERAL_DELAYED_PENALTY_ROLE"). */
@@ -138,6 +170,16 @@ declare function exit(ctx: Ctx, opts: {
138
170
  noId: bigint;
139
171
  exitedKeys: bigint;
140
172
  }): Promise<void>;
173
+ /** Remove `count` keys (default 1) from operator `noId` starting at `keyIndex`, as the operator's manager. */
174
+ declare function removeKey(ctx: Ctx, opts: {
175
+ noId: bigint;
176
+ keyIndex: bigint;
177
+ count?: bigint;
178
+ }): Promise<{
179
+ noId: bigint;
180
+ keyIndex: bigint;
181
+ count: bigint;
182
+ }>;
141
183
  //#endregion
142
184
  //#region src/recipes/deposit.d.ts
143
185
  /**
@@ -198,6 +240,30 @@ declare function withdraw(ctx: Ctx, opts: {
198
240
  exitBalance: bigint;
199
241
  slashingPenalty?: bigint;
200
242
  }): Promise<void>;
243
+ /**
244
+ * Activate `count` deposited-but-not-yet-active keys of an operator (Verifier-gated) by reporting
245
+ * an effective balance of 32 ETH + 1 gwei on each. Skips keys that already have a confirmed
246
+ * balance or are withdrawn. Port of `NodeOperators.activateKeys`. Returns the count activated.
247
+ */
248
+ declare function activateKeys(ctx: Ctx, opts: {
249
+ noId: bigint;
250
+ count: number;
251
+ }): Promise<{
252
+ activated: number;
253
+ }>;
254
+ /**
255
+ * Report an arbitrary CL balance (wei) for one deposited key (Verifier-gated). Validates the key
256
+ * index is in range and not withdrawn. Port of `NodeOperators.reportBalance`.
257
+ */
258
+ declare function reportBalance(ctx: Ctx, opts: {
259
+ noId: bigint;
260
+ keyIndex: bigint;
261
+ balanceWei: bigint;
262
+ }): Promise<{
263
+ noId: bigint;
264
+ keyIndex: bigint;
265
+ balanceWei: bigint;
266
+ }>;
201
267
  //#endregion
202
268
  //#region src/recipes/penalties.d.ts
203
269
  /** Report a general delayed penalty against an operator (penalty-reporter role). */
@@ -367,12 +433,60 @@ declare function getKeyBalance(ctx: Ctx, opts: {
367
433
  noId: bigint;
368
434
  keyIndex: bigint;
369
435
  }): Promise<bigint>;
436
+ interface BondCurveInterval {
437
+ minKeysCount: bigint;
438
+ minBond: bigint;
439
+ trend: bigint;
440
+ }
441
+ interface BondCurveInfo {
442
+ intervals: BondCurveInterval[];
443
+ }
444
+ /** Read a bond curve by id from Accounting (read-only). */
445
+ declare function getCurveInfo(ctx: Ctx, opts: {
446
+ curveId: bigint;
447
+ }): Promise<BondCurveInfo>;
448
+ interface BondInfo {
449
+ currentBond: bigint;
450
+ requiredBond: bigint;
451
+ lockedBond: bigint;
452
+ bondDebt: bigint;
453
+ pendingSharesToSplit: bigint;
454
+ }
455
+ /** Read an operator's bond summary from Accounting (read-only). */
456
+ declare function bondInfo(ctx: Ctx, opts: {
457
+ noId: bigint;
458
+ }): Promise<BondInfo>;
459
+ /** All of an operator's pubkeys (48 bytes each), in index order (read-only). */
460
+ declare function operatorKeys(ctx: Ctx, opts: {
461
+ noId: bigint;
462
+ }): Promise<Hex[]>;
463
+ /** All of an operator's deposited-key allocated balances (wei), in index order (read-only). */
464
+ declare function keyBalances(ctx: Ctx, opts: {
465
+ noId: bigint;
466
+ }): Promise<bigint[]>;
467
+ /** Total number of node operators in the module (read-only). */
468
+ declare function operatorsCount(ctx: Ctx): Promise<bigint>;
469
+ /** The highest node operator id (count - 1). Throws when there are no operators. */
470
+ declare function getLastOperator(ctx: Ctx): Promise<bigint>;
471
+ interface GateTree {
472
+ selector: string;
473
+ address: Hex;
474
+ treeRoot: Hex;
475
+ treeCid: string;
476
+ }
477
+ /** Read a gate's current merkle tree params (root + cid) by selector (read-only). */
478
+ declare function getGateTree(ctx: Ctx, opts: {
479
+ selector: string;
480
+ }): Promise<GateTree>;
370
481
  //#endregion
371
482
  //#region src/cl-mock.d.ts
372
483
  interface SetValidatorInput {
373
484
  pubkey: Hex;
374
- /** Only status clActivate sets; cl-mock's full union lives in the app, not here. */
375
- status: 'active_ongoing';
485
+ /**
486
+ * The CL statuses the recipes bridge sets: `active_ongoing` (clActivate) / `active_exiting`
487
+ * (exitRequest's optional flip). cl-mock's full status union lives in the app, not here.
488
+ */
489
+ status: 'active_ongoing' | 'active_exiting';
376
490
  /** Serialized to a gwei integer string on the wire; omitted when undefined. */
377
491
  effectiveBalanceGwei?: bigint;
378
492
  }
@@ -389,5 +503,65 @@ interface SetValidatorInput {
389
503
  */
390
504
  declare function setClValidator(clMockUrl: string, input: SetValidatorInput): Promise<void>;
391
505
  //#endregion
392
- export { type AddKeysOptions, type AddKeysResult, type ClActivateResult, type CmGateSelector, type ConnectOptions, type CsmGateSelector, type Ctx, DEFAULT_ADMIN_ROLE, type GateSelector, type MakeRewardsOptions, type OperatorInfo, REPORT_GENERAL_DELAYED_PENALTY_ROLE, RESUME_ROLE, type RecipeClient, type ResolvedAddresses, type RewardsReport, SETTLE_GENERAL_DELAYED_PENALTY_ROLE, SET_TREE_ROLE, type SetGateAddrsOptions, type SetGateAddrsResult, type SetValidatorInput, type SubmitRewardsResult, type WithdrawnValidatorInfo, actAs, addBond, addKeys, cancelPenalty, clActivate, compensatePenalty, confirmManager, confirmReward, connect, contract, createBondDebt, deposit, exit, getKeyBalance, getPubkey, increaseAllocatedBalance, keyCountBytes, makeClient, makeRewards, nodeOperatorIdBytes, operatorInfo, proposeManager, proposeReward, randomKeys, reportPenalty, resolveGate, revert, roleMember, setClValidator, setGateAddrs, settlePenalty, slash, snapshot, submitRewards, topUpActiveKeys, unvet, warpBy, warpTo, withdraw };
506
+ //#region src/recipes/pause.d.ts
507
+ interface PauseResult {
508
+ /** the target keyword as supplied (module | accounting | gate selector) */
509
+ target: string;
510
+ /** the resolved contract address */
511
+ address: Hex;
512
+ /** paused state after the call */
513
+ paused: boolean;
514
+ }
515
+ /** Pause a target (module | accounting | gate selector). Idempotent: no-op if already paused. */
516
+ declare function pause(ctx: Ctx, opts: {
517
+ target: string;
518
+ }): Promise<PauseResult>;
519
+ /** Resume a target (module | accounting | gate selector). Idempotent: no-op if not paused. */
520
+ declare function resume(ctx: Ctx, opts: {
521
+ target: string;
522
+ }): Promise<PauseResult>;
523
+ //#endregion
524
+ //#region src/recipes/exit-request.d.ts
525
+ interface ExitRequestOptions {
526
+ noId: bigint;
527
+ keyIndex: bigint;
528
+ /** CL validator index packed into the report. Defaults to 900000n (matches the just recipe). */
529
+ validatorIndex?: bigint;
530
+ }
531
+ interface ExitRequestResult {
532
+ noId: bigint;
533
+ keyIndex: bigint;
534
+ validatorIndex: bigint;
535
+ /** module id discovered in the StakingRouter. */
536
+ moduleId: bigint;
537
+ /** the report ref slot (= last consensus report refSlot + 1). */
538
+ refSlot: bigint;
539
+ /** keccak256(abi.encode(report)) submitted to VEBO. */
540
+ reportHash: Hex;
541
+ /** the 48-byte BLS pubkey exited. */
542
+ pubkey: Hex;
543
+ /** present iff ctx.clMockUrl was set: the validator was marked active_exiting on the cl-mock. */
544
+ clStatus?: 'active_exiting';
545
+ }
546
+ /**
547
+ * Request a single validator exit via the Validators Exit Bus Oracle. Port of
548
+ * `NodeOperators.s.sol:_exitRequest`. Reads the key pubkey + discovers the module id, packs the
549
+ * 64-byte exit request, then fakes VEBO consensus by impersonating the consensus contract
550
+ * (`submitConsensusReport`) and submits the data as the VEBO admin (`grantRole` + `submitReportData`).
551
+ *
552
+ * Module-agnostic: `contract(ctx,'module')` picks CSModule/CuratedModule by `ctx.module`, and the
553
+ * module-id scan matches that same address — no csm/cm branching.
554
+ *
555
+ * Optional cl-mock reflection (beyond the source): when `ctx.clMockUrl` is set, the validator is
556
+ * additionally marked `active_exiting` on the running cl-mock (mirroring `clActivate`); skipped
557
+ * silently otherwise.
558
+ *
559
+ * Deliberate divergences from the source (identical on-chain effect):
560
+ * - reuses the VEBO admin as the `submitReportData` submitter (source grants a fresh address);
561
+ * `grantRole` is idempotent so re-granting the admin never reverts.
562
+ * - scans ALL staking-module ids (source's `for (i=len-1; i>0; i--)` skips index 0).
563
+ */
564
+ declare function exitRequest(ctx: Ctx, opts: ExitRequestOptions): Promise<ExitRequestResult>;
565
+ //#endregion
566
+ export { type AddKeysOptions, type AddKeysResult, type BondCurveInfo, type BondCurveInterval, type BondInfo, type ClActivateResult, type CmGateSelector, type ConnectOptions, type CsmGateSelector, type Ctx, DEFAULT_ADMIN_ROLE, type ExitRequestOptions, type ExitRequestResult, type GateSelector, type GateTree, type MakeRewardsOptions, type OperatorInfo, PAUSE_ROLE, type PauseResult, REPORT_GENERAL_DELAYED_PENALTY_ROLE, RESUME_ROLE, type RecipeClient, type ResolvedAddresses, type RewardsReport, SETTLE_GENERAL_DELAYED_PENALTY_ROLE, SET_TREE_ROLE, type SetGateAddrsOptions, type SetGateAddrsResult, type SetTargetLimitOptions, type SetTargetLimitResult, type SetValidatorInput, type SubmitRewardsResult, type WithdrawnValidatorInfo, actAs, activateKeys, addBond, addKeys, bondInfo, cancelPenalty, clActivate, compensatePenalty, confirmManager, confirmReward, connect, contract, createBondDebt, deposit, exit, exitRequest, getCurveInfo, getGateTree, getKeyBalance, getLastOperator, getPubkey, increaseAllocatedBalance, keyBalances, keyCountBytes, makeClient, makeRewards, nodeOperatorIdBytes, operatorInfo, operatorKeys, operatorsCount, pause, proposeManager, proposeReward, randomKeys, removeKey, reportBalance, reportPenalty, resolveGate, resume, revert, roleMember, setClValidator, setGateAddrs, setTargetLimit, settlePenalty, slash, snapshot, submitRewards, topUpAccount, topUpActiveKeys, unvet, warpBy, warpTo, withdraw };
393
567
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/act-as.ts","../src/keys.ts","../src/recipes/add-keys.ts","../src/recipes/operator-info.ts","../src/recipes/chain.ts","../src/roles.ts","../src/recipes/address-changes.ts","../src/encode.ts","../src/recipes/vetting.ts","../src/recipes/deposit.ts","../src/recipes/topup.ts","../src/recipes/validators.ts","../src/recipes/penalties.ts","../src/recipes/bond.ts","../src/recipes/set-gate.ts","../src/recipes/rewards.ts","../src/recipes/cl-activate.ts","../src/recipes/reads.ts","../src/cl-mock.ts"],"mappings":";;;;;;;;;AAWA;;;iBAAsB,KAAA,IAAS,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,EAAA,GAAK,IAAA,EAAM,GAAA,KAAQ,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,CAAA;;iBAWrE,UAAA,CACpB,GAAA,EAAK,GAAA,EACL,MAAA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C7B,IAAA,GAAO,GAAA;EfhCgC;EekCvC,mBAAA,GAAsB,GAAG;EflC6B;EeoCtD,OAAA;EfpC4E;EesC5E,MAAA;EftCiF;EewCjF,GAAA;AAAA;AfxC0F;AAW5F;;;;;;;;;;;;AAX4F,iBewDtE,WAAA,CAAY,GAAA,EAAK,GAAA,EAAK,IAAA,GAAM,kBAAA,GAA0B,OAAA,CAAQ,aAAA;AAAA,UAsKnE,mBAAA;EfjNI;EemNnB,SAAA;EfnN6B;EeqN7B,OAAA;EfpNM;EesNN,QAAA,GAAW,GAAA;EfrNV;EeuND,UAAA,GAAa,GAAA;EfvND;EeyNZ,OAAA,GAAU,GAAA;AAAA;;;Ad9NZ;;;;;;;;;iBc4OsB,aAAA,CAAc,GAAA,EAAK,GAAA,EAAK,MAAA,EAAQ,aAAA,GAAgB,OAAA,CAAQ,mBAAA;;;UCzP7D,gBAAA;EACf,MAAA,EAAQ,GAAG;EACX,MAAA;EACA,oBAAA;AAAA;;;;;;;;iBAUoB,UAAA,CACpB,GAAA,EAAK,GAAA,EACL,IAAA;EAAQ,IAAA;EAAc,QAAA;AAAA,IACrB,OAAA,CAAQ,gBAAA;;;;iBCnBW,SAAA,CAAU,GAAA,EAAK,GAAA,EAAK,IAAA;EAAQ,IAAA;EAAc,QAAA;AAAA,IAAqB,OAAA,CAAQ,GAAA;;iBAkBvE,aAAA,CACpB,GAAA,EAAK,GAAA,EACL,IAAA;EAAQ,IAAA;EAAc,QAAA;AAAA,IACrB,OAAO;;;UChBO,iBAAA;EACf,MAAA,EAAQ,GAAG;ElBAiC;EkBE5C,MAAA;ElBF4E;EkBI5E,oBAAA;AAAA;;;;;;;;;;;;iBAmBoB,cAAA,CAAe,SAAA,UAAmB,KAAA,EAAO,iBAAA,GAAoB,OAAO"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/act-as.ts","../src/keys.ts","../src/recipes/add-keys.ts","../src/recipes/operator-info.ts","../src/recipes/chain.ts","../src/recipes/target-limit.ts","../src/roles.ts","../src/recipes/address-changes.ts","../src/encode.ts","../src/recipes/vetting.ts","../src/recipes/deposit.ts","../src/recipes/topup.ts","../src/recipes/validators.ts","../src/recipes/penalties.ts","../src/recipes/bond.ts","../src/recipes/set-gate.ts","../src/recipes/rewards.ts","../src/recipes/cl-activate.ts","../src/recipes/reads.ts","../src/cl-mock.ts","../src/recipes/pause.ts","../src/recipes/exit-request.ts"],"mappings":";;;;;;;;;AAWA;;;iBAAsB,KAAA,IAAS,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,EAAA,GAAK,IAAA,EAAM,GAAA,KAAQ,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,CAAA;;iBAWrE,UAAA,CACpB,GAAA,EAAK,GAAA,EACL,MAAA;EAAU,OAAA,EAAS,GAAA;EAAK,GAAA,EAAK,GAAA;AAAA,GAC7B,IAAA,EAAM,GAAA,GACL,OAAA,CAAQ,GAAA;;;;;;;;AAfX;;;iBCUsB,UAAA,CACpB,KAAA,UACA,IAAA,GAAO,GAAA,GACN,OAAA;EAAU,UAAA,EAAY,GAAA;EAAO,UAAA,EAAY,GAAA;EAAO,UAAA,EAAY,GAAA;EAAK,gBAAA,EAAkB,GAAA;AAAA;;;UCnBrE,cAAA;EACf,IAAA;EACA,KAAA;;EAEA,IAAA,GAAO,GAAG;AAAA;AAAA,UAGK,aAAA;EACf,UAAA,EAAY,GAAG;AAAA;;;;;iBAOK,OAAA,CAAQ,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,cAAA,GAAiB,OAAA,CAAQ,aAAA;;;;UChBtD,YAAA;EACf,cAAA;EACA,kBAAA;EACA,kBAAA;EACA,eAAA;EACA,oBAAA;EACA,0BAAA;EACA,WAAA;EACA,eAAA;EACA,eAAA;EACA,aAAA;EACA,cAAA,EAAgB,GAAA;EAChB,sBAAA,EAAwB,GAAA;EACxB,aAAA,EAAe,GAAA;EACf,qBAAA,EAAuB,GAAA;EACvB,0BAAA;EACA,iBAA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ACA,QAAA;EACA,cAAA;ErBb4E;EqBe5E,QAAA;ErBfyF;EqBiBzF,OAAA;ErBjBwF;EqBmBxF,UAAA,EAAY,GAAA;ErBnBc;EqBqB1B,MAAA,EAAQ,GAAG;ErBrBkB;EqBuB7B,QAAA;AAAA;;;;;;;;;ArBvB0F;AAW5F;;;;;;;;;iBqBgDsB,WAAA,CAAY,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,kBAAA,GAAqB,OAAA,CAAQ,iBAAA"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as contract, a as deposit, c as RESUME_ROLE, d as addKeys, f as randomKeys, g as connect, h as roleMember, i as getPubkey, l as SETTLE_GENERAL_DELAYED_PENALTY_ROLE, m as actAs, n as topUpActiveKeys, o as DEFAULT_ADMIN_ROLE, r as getKeyBalance, s as REPORT_GENERAL_DELAYED_PENALTY_ROLE, t as increaseAllocatedBalance, u as SET_TREE_ROLE, v as resolveGate, y as makeClient } from "./topup-B2NzJV7_.mjs";
2
- import { C as snapshot, E as operatorInfo, S as revert, T as warpTo, _ as nodeOperatorIdBytes, a as setGateAddrs, b as proposeManager, c as cancelPenalty, d as settlePenalty, f as slash, g as keyCountBytes, h as unvet, i as submitRewards, l as compensatePenalty, m as exit, n as setClValidator, o as addBond, p as withdraw, r as makeRewards, s as createBondDebt, t as clActivate, u as reportPenalty, v as confirmManager, w as warpBy, x as proposeReward, y as confirmReward } from "./cl-activate-CPqr6v_D.mjs";
3
- export { DEFAULT_ADMIN_ROLE, REPORT_GENERAL_DELAYED_PENALTY_ROLE, RESUME_ROLE, SETTLE_GENERAL_DELAYED_PENALTY_ROLE, SET_TREE_ROLE, actAs, addBond, addKeys, cancelPenalty, clActivate, compensatePenalty, confirmManager, confirmReward, connect, contract, createBondDebt, deposit, exit, getKeyBalance, getPubkey, increaseAllocatedBalance, keyCountBytes, makeClient, makeRewards, nodeOperatorIdBytes, operatorInfo, proposeManager, proposeReward, randomKeys, reportPenalty, resolveGate, revert, roleMember, setClValidator, setGateAddrs, settlePenalty, slash, snapshot, submitRewards, topUpActiveKeys, unvet, warpBy, warpTo, withdraw };
1
+ import { C as roleMember, D as makeClient, E as resolveGate, S as actAs, T as contract, _ as SETTLE_GENERAL_DELAYED_PENALTY_ROLE, a as getGateTree, b as randomKeys, c as getPubkey, d as operatorsCount, f as deposit, g as RESUME_ROLE, h as REPORT_GENERAL_DELAYED_PENALTY_ROLE, i as getCurveInfo, l as keyBalances, m as PAUSE_ROLE, n as topUpActiveKeys, o as getKeyBalance, p as DEFAULT_ADMIN_ROLE, r as bondInfo, s as getLastOperator, t as increaseAllocatedBalance, u as operatorKeys, v as SET_TREE_ROLE, w as connect, y as addKeys } from "./topup-CuqmB14u.mjs";
2
+ import { A as snapshot, C as nodeOperatorIdBytes, D as proposeReward, E as proposeManager, M as warpBy, N as warpTo, O as setTargetLimit, P as operatorInfo, S as keyCountBytes, T as confirmReward, _ as slash, a as setClValidator, b as removeKey, c as setGateAddrs, d as cancelPenalty, f as compensatePenalty, g as reportBalance, h as activateKeys, i as clActivate, j as topUpAccount, k as revert, l as addBond, m as settlePenalty, n as pause, o as makeRewards, p as reportPenalty, r as resume, s as submitRewards, t as exitRequest, u as createBondDebt, v as withdraw, w as confirmManager, x as unvet, y as exit } from "./exit-request-c0CS5wKu.mjs";
3
+ export { DEFAULT_ADMIN_ROLE, PAUSE_ROLE, REPORT_GENERAL_DELAYED_PENALTY_ROLE, RESUME_ROLE, SETTLE_GENERAL_DELAYED_PENALTY_ROLE, SET_TREE_ROLE, actAs, activateKeys, addBond, addKeys, bondInfo, cancelPenalty, clActivate, compensatePenalty, confirmManager, confirmReward, connect, contract, createBondDebt, deposit, exit, exitRequest, getCurveInfo, getGateTree, getKeyBalance, getLastOperator, getPubkey, increaseAllocatedBalance, keyBalances, keyCountBytes, makeClient, makeRewards, nodeOperatorIdBytes, operatorInfo, operatorKeys, operatorsCount, pause, proposeManager, proposeReward, randomKeys, removeKey, reportBalance, reportPenalty, resolveGate, resume, revert, roleMember, setClValidator, setGateAddrs, setTargetLimit, settlePenalty, slash, snapshot, submitRewards, topUpAccount, topUpActiveKeys, unvet, warpBy, warpTo, withdraw };
@@ -25,6 +25,15 @@ const CM_SELECTORS = {
25
25
  iodc: 5,
26
26
  iodcp: 6
27
27
  };
28
+ const CM_GATE_KEYS = [
29
+ "CuratedGatePO",
30
+ "CuratedGatePTO",
31
+ "CuratedGatePGO",
32
+ "CuratedGateDO",
33
+ "CuratedGateEEO",
34
+ "CuratedGateIODC",
35
+ "CuratedGateIODCP"
36
+ ];
28
37
  function defaultSnapshot(chainId, module) {
29
38
  for (const chainKey of Object.keys(addresses)) {
30
39
  const book = addresses[chainKey][module];
@@ -115,23 +124,23 @@ function contract(ctx, name) {
115
124
  }
116
125
  /**
117
126
  * Resolve a gate selector to an address (the `_resolve-gate-addr` port). Accepted forms:
118
- * a raw `0x…` 40-hex address (any module); for csm — `ics` → VettedGate, `idvtc` →
119
- * IdentifiedDVTClusterGate (v3-only; throws on snapshots lacking it, e.g. mainnet/v2);
120
- * for cm — `po|pto|pgo|do|eeo|iodc|iodcp` or a numeric index → `CuratedGates[0..6]`.
127
+ * a raw `0x…` 40-hex address (any module); for csm — `ics` → IcsGate, `idvtc` →
128
+ * IdvtcGate (v3-only; throws on pre-v3 snapshots lacking it);
129
+ * for cm — `po|pto|pgo|do|eeo|iodc|iodcp` or a numeric index → the named curated gates.
121
130
  */
122
131
  function resolveGate(ctx, selector) {
123
132
  if (/^0x[0-9a-fA-F]{40}$/.test(selector)) return selector;
124
133
  if (ctx.module === "cm") {
125
134
  const idx = CM_SELECTORS[selector] ?? (/^\d+$/.test(selector) ? Number(selector) : void 0);
126
135
  if (idx === void 0) throw new Error(`@sm-lab/recipes: unknown cm gate selector "${selector}"`);
127
- const gate = ctx.addresses.CuratedGates[idx];
128
- if (!gate) throw new Error(`@sm-lab/recipes: cm gate index ${idx} out of range`);
129
- return gate;
136
+ const key = CM_GATE_KEYS[idx];
137
+ if (!key) throw new Error(`@sm-lab/recipes: cm gate index ${idx} out of range`);
138
+ return ctx.addresses[key];
130
139
  }
131
- if (selector === "ics") return ctx.addresses.VettedGate;
140
+ if (selector === "ics") return ctx.addresses.IcsGate;
132
141
  if (selector === "idvtc") {
133
- const g = ctx.addresses.IdentifiedDVTClusterGate;
134
- if (!g) throw new Error("@sm-lab/recipes: idvtc gate not in this snapshot (v3-only; absent on mainnet/v2)");
142
+ const g = ctx.addresses.IdvtcGate;
143
+ if (!g) throw new Error("@sm-lab/recipes: idvtc gate not in this snapshot (v3-only; absent pre-v3)");
135
144
  return g;
136
145
  }
137
146
  throw new Error(`@sm-lab/recipes: unknown csm gate selector "${selector}"`);
@@ -254,6 +263,8 @@ const DEFAULT_ADMIN_ROLE = `0x${"0".repeat(64)}`;
254
263
  const SET_TREE_ROLE = keccak256(toBytes("SET_TREE_ROLE"));
255
264
  /** PausableWithRoles: keccak256("RESUME_ROLE"). */
256
265
  const RESUME_ROLE = keccak256(toBytes("RESUME_ROLE"));
266
+ /** PausableWithRoles: keccak256("PAUSE_ROLE"). */
267
+ const PAUSE_ROLE = keccak256(toBytes("PAUSE_ROLE"));
257
268
  /** BaseModule: keccak256("REPORT_GENERAL_DELAYED_PENALTY_ROLE"). */
258
269
  const REPORT_GENERAL_DELAYED_PENALTY_ROLE = keccak256(toBytes("REPORT_GENERAL_DELAYED_PENALTY_ROLE"));
259
270
  /** BaseModule: keccak256("SETTLE_GENERAL_DELAYED_PENALTY_ROLE"). */
@@ -329,6 +340,101 @@ async function getKeyBalance(ctx, opts) {
329
340
  if (wei === void 0) throw new Error(`@sm-lab/recipes: no allocated balance for operator ${opts.noId} at index ${opts.keyIndex}`);
330
341
  return wei;
331
342
  }
343
+ /** Read a bond curve by id from Accounting (read-only). */
344
+ async function getCurveInfo(ctx, opts) {
345
+ const acc = contract(ctx, "Accounting");
346
+ return await ctx.client.readContract({
347
+ ...acc,
348
+ functionName: "getCurveInfo",
349
+ args: [opts.curveId]
350
+ });
351
+ }
352
+ /** Read an operator's bond summary from Accounting (read-only). */
353
+ async function bondInfo(ctx, opts) {
354
+ const acc = contract(ctx, "Accounting");
355
+ return await ctx.client.readContract({
356
+ ...acc,
357
+ functionName: "getNodeOperatorBondInfo",
358
+ args: [opts.noId]
359
+ });
360
+ }
361
+ /** All of an operator's pubkeys (48 bytes each), in index order (read-only). */
362
+ async function operatorKeys(ctx, opts) {
363
+ const m = contract(ctx, "module");
364
+ const total = (await ctx.client.readContract({
365
+ ...m,
366
+ functionName: "getNodeOperator",
367
+ args: [opts.noId]
368
+ })).totalAddedKeys;
369
+ if (total === 0) return [];
370
+ const hex = (await ctx.client.readContract({
371
+ ...m,
372
+ functionName: "getSigningKeys",
373
+ args: [
374
+ opts.noId,
375
+ 0n,
376
+ BigInt(total)
377
+ ]
378
+ })).slice(2);
379
+ const keys = [];
380
+ for (let i = 0; i < total; i++) keys.push(`0x${hex.slice(i * 96, (i + 1) * 96)}`);
381
+ return keys;
382
+ }
383
+ /** All of an operator's deposited-key allocated balances (wei), in index order (read-only). */
384
+ async function keyBalances(ctx, opts) {
385
+ const m = contract(ctx, "module");
386
+ const total = (await ctx.client.readContract({
387
+ ...m,
388
+ functionName: "getNodeOperator",
389
+ args: [opts.noId]
390
+ })).totalDepositedKeys;
391
+ if (total === 0) return [];
392
+ return [...await ctx.client.readContract({
393
+ ...m,
394
+ functionName: "getKeyAllocatedBalances",
395
+ args: [
396
+ opts.noId,
397
+ 0n,
398
+ BigInt(total)
399
+ ]
400
+ })];
401
+ }
402
+ /** Total number of node operators in the module (read-only). */
403
+ async function operatorsCount(ctx) {
404
+ const m = contract(ctx, "module");
405
+ return await ctx.client.readContract({
406
+ ...m,
407
+ functionName: "getNodeOperatorsCount"
408
+ });
409
+ }
410
+ /** The highest node operator id (count - 1). Throws when there are no operators. */
411
+ async function getLastOperator(ctx) {
412
+ const count = await operatorsCount(ctx);
413
+ if (count === 0n) throw new Error("@sm-lab/recipes: no node operators");
414
+ return count - 1n;
415
+ }
416
+ /** Read a gate's current merkle tree params (root + cid) by selector (read-only). */
417
+ async function getGateTree(ctx, opts) {
418
+ const address = resolveGate(ctx, opts.selector);
419
+ const gate = {
420
+ address,
421
+ abi: ctx.module === "cm" ? curatedGateAbi : vettedGateAbi
422
+ };
423
+ const treeRoot = await ctx.client.readContract({
424
+ ...gate,
425
+ functionName: "treeRoot"
426
+ });
427
+ const treeCid = await ctx.client.readContract({
428
+ ...gate,
429
+ functionName: "treeCid"
430
+ });
431
+ return {
432
+ selector: opts.selector,
433
+ address,
434
+ treeRoot,
435
+ treeCid
436
+ };
437
+ }
332
438
  //#endregion
333
439
  //#region src/recipes/topup.ts
334
440
  /** Per-key top-up cap (2016 ether). Matches `NodeOperators.MAX_TOPUP_PER_KEY`. */
@@ -432,6 +538,6 @@ async function topUpActiveKeys(ctx, opts) {
432
538
  return { toppedUp: workList.length };
433
539
  }
434
540
  //#endregion
435
- export { contract as _, deposit as a, RESUME_ROLE as c, addKeys as d, randomKeys as f, connect as g, roleMember as h, getPubkey as i, SETTLE_GENERAL_DELAYED_PENALTY_ROLE as l, actAs as m, topUpActiveKeys as n, DEFAULT_ADMIN_ROLE as o, randomSeed as p, getKeyBalance as r, REPORT_GENERAL_DELAYED_PENALTY_ROLE as s, increaseAllocatedBalance as t, SET_TREE_ROLE as u, resolveGate as v, makeClient as y };
541
+ export { roleMember as C, makeClient as D, resolveGate as E, actAs as S, contract as T, SETTLE_GENERAL_DELAYED_PENALTY_ROLE as _, getGateTree as a, randomKeys as b, getPubkey as c, operatorsCount as d, deposit as f, RESUME_ROLE as g, REPORT_GENERAL_DELAYED_PENALTY_ROLE as h, getCurveInfo as i, keyBalances as l, PAUSE_ROLE as m, topUpActiveKeys as n, getKeyBalance as o, DEFAULT_ADMIN_ROLE as p, bondInfo as r, getLastOperator as s, increaseAllocatedBalance as t, operatorKeys as u, SET_TREE_ROLE as v, connect as w, randomSeed as x, addKeys as y };
436
542
 
437
- //# sourceMappingURL=topup-B2NzJV7_.mjs.map
543
+ //# sourceMappingURL=topup-CuqmB14u.mjs.map