Skip to content

Feat/optional total supply#795

Open
ozgunozerk wants to merge 3 commits into
mainfrom
feat/optional-total-supply
Open

Feat/optional total supply#795
ozgunozerk wants to merge 3 commits into
mainfrom
feat/optional-total-supply

Conversation

@ozgunozerk

@ozgunozerk ozgunozerk commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #560

PR Checklist

  • Tests
  • Documentation

@brozorec, here is the PR that we were talking about, please take your time for reviewing it, because this is an important change. We should put our best effort into it to make it the "finalized" and "future proof" version if possible

Summary by CodeRabbit

  • New Features

    • Added opt-in total supply tracking for fungible tokens, including mint, burn, and supply queries.
    • Added composable token extensions for combining transfer policies with total supply tracking.
    • Added composition support for non-fungible token extensions.
    • Updated token examples to use the new composition and total supply capabilities.
  • Documentation

    • Clarified extension behavior, supported combinations, and total supply requirements across token and vault examples.

@ozgunozerk
ozgunozerk requested a review from brozorec July 14, 2026 12:38
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR introduces Compose-based token contract composition, separates fungible total-supply tracking into an opt-in extension, adds composed allowlist/blocklist combinations, updates supply-aware integrations, and migrates token examples and documentation to the new APIs.

Changes

Token architecture

Layer / File(s) Summary
Fungible total-supply extension
packages/tokens/src/fungible/...
Adds total-supply storage, mutation helpers, override routing, validation tests, and removes total-supply bookkeeping from Base.
Fungible contract composition
packages/tokens/src/fungible/extensions/combinations/*, packages/tokens/src/fungible/extensions/{allowlist,blocklist}/*
Adds Compose, supported composed contract types, and policy marker bounds for allowlist/blocklist extensions.
Supply-aware integrations
packages/tokens/src/fungible/extensions/votes/*, packages/tokens/src/rwa/*, packages/tokens/src/vault/*
Routes votes, RWA, and vault supply behavior through total-supply overrides and helpers.
Non-fungible contract composition
packages/tokens/src/non_fungible/*
Adds non-fungible Compose resolution and updates supported contract type documentation.
Example contract migrations
examples/*, Architecture.md
Updates fungible and non-fungible examples to use composed contract types and explicit total-supply traits or helpers.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: brozorec

Poem

I’m a rabbit composing types,
With supply-safe hops and checks.
Allowlists guard, vault shares grow,
Votes keep their totals in flow.
New examples bloom in the queue—
Compose makes the token view true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template fields are present, but the actual PR description is mostly unfilled template text and lacks a real change summary. Add a short summary of the feature, the main implementation changes, and any important context beyond the template comments.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main feature: optional total supply.
Linked Issues check ✅ Passed The changes implement a Compose-based architecture and marker traits that support valid extension combinations, matching issue #560's composability goal.
Out of Scope Changes check ✅ Passed All code, tests, and docs appear tied to optional total supply and the new composition architecture, with no clear unrelated changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/optional-total-supply

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.66667% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.04%. Comparing base (7a3cd00) to head (f3263ca).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ns/src/fungible/extensions/combinations/storage.rs 63.79% 21 Missing ⚠️
...ns/src/fungible/extensions/total_supply/storage.rs 86.27% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #795      +/-   ##
==========================================
- Coverage   96.63%   96.04%   -0.60%     
==========================================
  Files          72       73       +1     
  Lines        7615     7451     -164     
==========================================
- Hits         7359     7156     -203     
- Misses        256      295      +39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/tokens/src/fungible/extensions/combinations/mod.rs (1)

87-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce repetition in single-type Composable impls.

14 near-identical impls (bare type + 1-tuple, same Out) for 7 types. A small macro keeps the mapping in one place and removes the risk of forgetting the tuple form when a new contract type is added.

♻️ Proposed macro-based refactor
+macro_rules! impl_composable_single {
+    ($($ty:ty),* $(,)?) => {
+        $(
+            impl Composable for $ty {
+                type Out = $ty;
+            }
+            impl Composable for ($ty,) {
+                type Out = $ty;
+            }
+        )*
+    };
+}
+
-impl Composable for Base {
-    type Out = Base;
-}
-impl Composable for (Base,) {
-    type Out = Base;
-}
-impl Composable for AllowList {
-    type Out = AllowList;
-}
-impl Composable for (AllowList,) {
-    type Out = AllowList;
-}
-impl Composable for BlockList {
-    type Out = BlockList;
-}
-impl Composable for (BlockList,) {
-    type Out = BlockList;
-}
-impl Composable for TotalSupply {
-    type Out = TotalSupply;
-}
-impl Composable for (TotalSupply,) {
-    type Out = TotalSupply;
-}
-impl Composable for RWA {
-    type Out = RWA;
-}
-impl Composable for (RWA,) {
-    type Out = RWA;
-}
-impl Composable for Vault {
-    type Out = Vault;
-}
-impl Composable for (Vault,) {
-    type Out = Vault;
-}
-impl Composable for FungibleVotes {
-    type Out = FungibleVotes;
-}
-impl Composable for (FungibleVotes,) {
-    type Out = FungibleVotes;
-}
+impl_composable_single!(Base, AllowList, BlockList, TotalSupply, RWA, Vault, FungibleVotes);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tokens/src/fungible/extensions/combinations/mod.rs` around lines 87
- 131, Replace the repeated single-type Composable implementations with a small
macro that generates both the bare-type and one-element tuple implementations
with the same Out mapping. Invoke it once for each of Base, AllowList,
BlockList, TotalSupply, RWA, Vault, and FungibleVotes, preserving the existing
resolution behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/tokens/src/fungible/extensions/combinations/mod.rs`:
- Around line 87-131: Replace the repeated single-type Composable
implementations with a small macro that generates both the bare-type and
one-element tuple implementations with the same Out mapping. Invoke it once for
each of Base, AllowList, BlockList, TotalSupply, RWA, Vault, and FungibleVotes,
preserving the existing resolution behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56514609-a954-4a7c-90b7-957fbb8c277f

📥 Commits

Reviewing files that changed from the base of the PR and between 1e51389 and f3263ca.

📒 Files selected for processing (46)
  • Architecture.md
  • examples/fungible-allowlist/src/contract.rs
  • examples/fungible-blocklist/src/contract.rs
  • examples/fungible-capped/src/contract.rs
  • examples/fungible-governor-timelock/token/src/token.rs
  • examples/fungible-governor/token/src/token.rs
  • examples/fungible-pausable/src/contract.rs
  • examples/fungible-vault/src/contract.rs
  • examples/fungible-votes/src/contract.rs
  • examples/nft-access-control/src/contract.rs
  • examples/nft-consecutive/src/contract.rs
  • examples/nft-enumerable/src/contract.rs
  • examples/nft-royalties/src/contract.rs
  • examples/nft-sequential-minting/src/contract.rs
  • examples/rwa/token/src/contract.rs
  • packages/tokens/src/fungible/extensions/allowlist/mod.rs
  • packages/tokens/src/fungible/extensions/blocklist/mod.rs
  • packages/tokens/src/fungible/extensions/burnable/mod.rs
  • packages/tokens/src/fungible/extensions/burnable/storage.rs
  • packages/tokens/src/fungible/extensions/burnable/test.rs
  • packages/tokens/src/fungible/extensions/capped/mod.rs
  • packages/tokens/src/fungible/extensions/capped/test.rs
  • packages/tokens/src/fungible/extensions/combinations/mod.rs
  • packages/tokens/src/fungible/extensions/combinations/storage.rs
  • packages/tokens/src/fungible/extensions/combinations/test.rs
  • packages/tokens/src/fungible/extensions/mod.rs
  • packages/tokens/src/fungible/extensions/total_supply/mod.rs
  • packages/tokens/src/fungible/extensions/total_supply/storage.rs
  • packages/tokens/src/fungible/extensions/total_supply/test.rs
  • packages/tokens/src/fungible/extensions/votes/storage.rs
  • packages/tokens/src/fungible/extensions/votes/test.rs
  • packages/tokens/src/fungible/mod.rs
  • packages/tokens/src/fungible/overrides.rs
  • packages/tokens/src/fungible/storage.rs
  • packages/tokens/src/fungible/test.rs
  • packages/tokens/src/non_fungible/extensions/burnable/mod.rs
  • packages/tokens/src/non_fungible/extensions/combinations/mod.rs
  • packages/tokens/src/non_fungible/extensions/mod.rs
  • packages/tokens/src/non_fungible/mod.rs
  • packages/tokens/src/non_fungible/overrides.rs
  • packages/tokens/src/rwa/mod.rs
  • packages/tokens/src/rwa/storage.rs
  • packages/tokens/src/rwa/test.rs
  • packages/tokens/src/vault/mod.rs
  • packages/tokens/src/vault/storage.rs
  • packages/tokens/src/vault/test.rs
💤 Files with no reviewable changes (2)
  • packages/tokens/src/fungible/test.rs
  • packages/tokens/src/fungible/extensions/burnable/test.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🏗️ [Core Feature]: Have a better architecture to enforce mutual exclusivity, without limiting composability and worsening DevX

1 participant