pub fn prepare_transfer_with_authorization(
domain: Eip3009Domain,
authorization: TransferWithAuthorizationInput,
binding: &ApprovalBinding,
now_unix_seconds: u64,
nonce_store: &dyn Eip3009NonceStore,
) -> Result<PreparedTransferWithAuthorization, SettlementError>Expand description
Prepare an EIP-3009 transferWithAuthorization digest, enforcing the
money-safety invariants before any signature is broadcast:
- Single-use nonce.
nonce_store.record_if_fresh(from, nonce)is consulted first; a previously-seen(from, nonce)pair fails closed withSettlementError::InvalidBinding, rejecting replays. - Time window vs. now. The authorization is accepted only when
valid_before > now_unix_seconds > valid_after; an expired or not-yet-valid window fails closed. - Authorization must not outlive the approval. The EIP-3009
valid_beforemust not exceedbinding.approval_expires_at. A signed transfer stays broadcastable on-chain untilvalid_before, so an authorization whose window outlasts the governing approval is rejected to keep the off-chain spend bounded by the approval window. - Approval binding. The domain
chain_id, authorizationto(payee),value(amount), and token identity (the domainverifying_contractagainst the REQUIREDbinding.token_contract) are asserted againstbinding; any mismatch (or an absent token contract) fails closed. The caller resolvesbindingfrom the verified governing approval from governed approval validation.
All checks fail closed. The nonce is recorded only after the time-window, expiry, and binding checks pass, so a rejected authorization does not burn its nonce.