/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { Ctx, Operation, Outcome } from '../contract.js'; import type { Unit } from '../ports.js'; /** * Undoes an earlier transaction by posting its exact opposite: an operator-only manual correction * that posts the original's legs with every amount's sign flipped, locking each account it touched * first. A transaction is reversed at most once via the shared `reversed:${txnId}` key (the pattern * refund and clawback use); a second reverse returns the first reversal as a `duplicate`. Reversing * a reversal is refused with `OP.MALFORMED`, as it would just loop the money back out and in. * * @example * const outcome = await reverse( * { kind: 'reverse', idempotencyKey: 'idem_0', * actor: { kind: 'operator', operatorId: 'op_1' }, * txnId: 'txn_1', reason: 'reconciliation: duplicate posting' }, * unit, ctx, * ); * // outcome.status === 'committed'; every leg of txn_1 posted with its sign flipped. * * @see {@link https://economy-lab-docs.pages.dev/economy/reference/operations/reverse/ Reverse} for * the operator-only undo-by-inverse correction flow. */ export declare function reverse(operation: Operation, unit: Unit, ctx: Ctx): Promise;