Raxol.Payments.SpendingHook (Raxol Payments v0.2.0)

Copy Markdown View Source

CommandHook that enforces spending policy on payment operations.

Integrates with the agent harness hook chain to check budget before allowing payment-related commands. Requires a Ledger and SpendingPolicy to be configured in the hook context.

Setup

defmodule MyAgent do
  use Raxol.Agent

  def command_hooks do
    Raxol.Payments.SpendingHook.set_config(%{
      ledger: :my_ledger,
      policy: SpendingPolicy.dev()
    })

    [Raxol.Payments.SpendingHook]
  end
end

Summary

Functions

Get the active config from the process dictionary.

Store spending hook config in the process dictionary.

Types

config()

@type config() :: %{
  :ledger => GenServer.server(),
  :policy => Raxol.Payments.SpendingPolicy.t(),
  optional(:on_confirm) => Raxol.Payments.PolicyGate.confirm_fn()
}

Functions

get_config()

@spec get_config() :: config() | nil

Get the active config from the process dictionary.

set_config(config)

@spec set_config(config()) :: :ok

Store spending hook config in the process dictionary.