Skip to main content
A denied action aborts on-chain and emits no event, so a chain indexer never sees it. guardedSubmit makes denials visible: it dry-runs the transaction first, and on a policy abort it records the denial and returns without submitting — no gas burned. An allowed transaction submits for real and the chain event indexes it.

What it does

  1. devInspectTransactionBlock to dry-run the PTB as sender.
  2. dryRunResult classifies the effects. On success, submit via exec.
  3. On a policy abort, post a denied audit row with the decoded reason and return { ok: false, reason_code }. The transaction is never submitted.
  4. On a non-policy failure (DeepBook liquidity, gas), return { ok: false } with no reason_code and no audit row. That is not a policy decision; surface it rather than recording a denial.
The audit post is best-effort and never blocks trading. A failed post is swallowed.

dryRunResult

Pure classifier. Reads effects.status; on failure decodes the policy abort. Use it when you run devInspect yourself and want to branch on the outcome without submitting.
A swap that passes the dry-run is a policy decision, not a guaranteed fill. The agent submits a gated DeepBook order; on a thin testnet book it may fill zero. ok: true means the policy permitted the action and the transaction landed.

Reads and decodePolicyAbort

Read live state from chain and map abort codes to reasons.