feat(fees): v0.0.20 pallet-origin-fees scaffold trait-first + vendor OitFeeSchedule Mathi (OCAFB-1..6)

Phase 2.4 FEES pallet scaffold canonical pattern análogo Phase 2.1 (scaffold →
wired → impl → Runtime API). New crate `origin-chain-fees` con vendor copy
Mathi OitFeeSchedule trait + matrices + Mock desde commit ce4fafb (536 LOC).

## Cross-pillar source-of-truth canonical

NEW canonical: `origin-chain-types::actions::ChainAction` (OCAFB-2). Mathi
local mirror puede swap post-OCAFB ratify 7/7 (deadline 2026-06-21).
NEW canonical: `origin-chain-types::tiers::SubscriptionTier` (mirror Mathi).

## Surface canonical scaffold v0.0.20

- Pallet<T> + Config trait + RuntimeEvent
- AccountFees<StorageMap<AccountId, FeeHistory>> per-account history
- FeeHistory { total_paid, action_count } aggregate stats
- Events FeeCharged + FeeRefunded + EntitlementBlocked
- Errors InsufficientBalance + EntitlementLocked + FeeOverflow + AccountNotFound
- FeeRejectionReason enum (mirror PROV pattern Phase 2.1)
- Scaffold dispatchable compute_fee_for_action (placeholder event v0.0.20 → real v0.0.22)

## Vendor copy OitFeeSchedule canonical

- OitFeeSchedule trait 4-method dyn-compatible Send + Sync (OCAFB-1)
- subsidy_basis_points const fn matrix Inmutable #16 anti-clasista (OCAFB-3)
- entitlement_unlocked const fn matrix Inmutables #37 + #18 (OCAFB-4)
- compute_fee formula 3-step (OCAFB-5)
- OitFeeScheduleMock builder pattern (OCAFB-6)
- arc_mock() helper canonical Arc<dyn OitFeeSchedule>

## Files canonical

- NEW: crates/origin-chain-fees/Cargo.toml (mirror provenance pattern)
- NEW: crates/origin-chain-fees/src/lib.rs (~250 LOC pallet scaffold)
- NEW: crates/origin-chain-fees/src/fee_schedule.rs (~400 LOC vendor copy)
- NEW: crates/origin-chain-types/src/actions.rs (~130 LOC ChainAction canonical)
- EDIT: crates/origin-chain-types/src/tiers.rs (SubscriptionTier added)
- EDIT: crates/origin-chain-types/src/lib.rs (mod actions + re-exports)
- EDIT: Cargo.toml (workspace member origin-chain-fees)
- EDIT: CHANGELOG.md (v0.0.20 entry pattern Phase 2.1)

## Verification

- cargo build -p origin-chain-fees 1.83s clean
- cargo test -p origin-chain-fees — 20 tests verde, 0 failures
  (16 vendor + 4 pallet scaffold)
- cargo test -p origin-chain-types — 55 tests passing (+8 nuevos)
  (6 ChainAction + 2 SubscriptionTier)
- Zero workspace compile errors

🚀 Phase 2.4 scaffold canonical ready. Wire pattern v0.0.21 next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
davidherranandClaude Opus 4.7 committed 2026-05-24 22:47:26 -05:00
1 parent 654cffdf31
commit 33b10b7545
9 files changed
+1090 -1

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
[package]
name = "origin-chain-fees"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
description = "Cross-pillar fee economy pallet canonical per OCAFB-1..6 + Mathi OitFeeSchedule consumer. Phase 2.4 scaffold v0.0.20 trait-first foundation — consumer Mathi commit ce4fafb (arkhe-amis-server::fee_schedule) via vendor copy interim Option B (swap canonical post-OCAFB ratify o post Mathi sub-crate ship)."
[dependencies]
# Origin Chain canonical types (ChainAction + HardwareTier + SubscriptionTier source-of-truth)
origin-chain-types = { workspace = true }
# FRAME canonical pallet macro + storage + dispatch + events + errors
frame-support = { workspace = true }
frame-system = { workspace = true }
# Runtime API canonical (v0.0.23 — FeesApi.query_fee_for_action read-only RPC query)
sp-api = { workspace = true }
# SCALE codec canonical
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
[dev-dependencies]
# Mock runtime canonical para integration tests v0.0.22 — Pattern v0.0.18 mirror.
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
[features]
default = ["std"]
std = [
"origin-chain-types/std",
"frame-support/std",
"frame-system/std",
"sp-api/std",
"parity-scale-codec/std",
"scale-info/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]