@pwngh/economy-lab
    Preparing search index...

    Variable reverseConst

    reverse: (
        fields: FieldsOf<K>,
    ) => {
        actor: Principal;
        idempotencyKey: string;
        kind: "reverse";
        reason: string;
        txnId: string;
    } = ...

    Builds a reverse operation: the operator's manual undo of a prior posting. It loads the transaction named by txnId, locks every account it touched, and posts its exact opposite — same accounts, every leg's sign flipped — so the reversal balances without recomputation. A reversal itself cannot be reversed: undoing an undo would let an operator loop money at will, so a txnId marked kind: "reverse" is refused. Operator-only; the handler refuses even a system caller. It has no rejected path — an unknown txnId faults OP.MALFORMED. A transaction is reversed at most once through the shared reversed:<txnId> claim (the same family refund and clawback use): a second reverse, or a retry under the same idempotencyKey, returns the first reversal as duplicate. For an in-flight payout, use reversePayout instead, which unwinds the saga rather than flipping ledger legs.

    Type Declaration

      • (
            fields: FieldsOf<K>,
        ): {
            actor: Principal;
            idempotencyKey: string;
            kind: "reverse";
            reason: string;
            txnId: string;
        }
      • Parameters

        • fields: FieldsOf<K>

        Returns {
            actor: Principal;
            idempotencyKey: string;
            kind: "reverse";
            reason: string;
            txnId: string;
        }

    const outcome = await economy.submit(reverse({
    idempotencyKey: idempotencyKey('undo', 'txn_5f21'),
    actor: operatorActor('op_7'),
    txnId: 'txn_5f21',
    reason: 'reconciliation: duplicate posting',
    }));