Raxol.Payments.Mandate.Check (Raxol Payments v0.2.0)

Copy Markdown View Source

Select the best Mandate envelope from the Store for a given scope and agent wallet.

Pure module. No state. Reads from Raxol.Payments.Mandate.Store.

Selection strategy

Among the mandates an agent can present for a given scope, returns the one with the soonest expires_at. This drains short-lived envelopes first, leaving longer-lived ones available for later calls -- the same heuristic Permit2 callers use for nonce ordering.

Expired mandates are filtered out. Unsigned mandates can't be in the Store in the first place (the Store rejects them in put/2).

Summary

Functions

Find the soonest-expiring active Mandate that covers scope and is addressed to agent_wallet.

Functions

select_for_scope(scope, agent_wallet)

@spec select_for_scope(Raxol.Payments.Mandate.scope(), String.t()) ::
  {:ok, Raxol.Payments.Mandate.t()} | {:error, :no_mandate}

Find the soonest-expiring active Mandate that covers scope and is addressed to agent_wallet.

Reads from the singleton Raxol.Payments.Mandate.Store. The Store is a singleton (named ETS tables), so there is no store argument to swap targets -- start exactly one Store per node.