Feat/optional total supply - #795
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR introduces ChangesToken architecture
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/tokens/src/fungible/extensions/combinations/mod.rs (1)
87-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce repetition in single-type
Composableimpls.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
📒 Files selected for processing (46)
Architecture.mdexamples/fungible-allowlist/src/contract.rsexamples/fungible-blocklist/src/contract.rsexamples/fungible-capped/src/contract.rsexamples/fungible-governor-timelock/token/src/token.rsexamples/fungible-governor/token/src/token.rsexamples/fungible-pausable/src/contract.rsexamples/fungible-vault/src/contract.rsexamples/fungible-votes/src/contract.rsexamples/nft-access-control/src/contract.rsexamples/nft-consecutive/src/contract.rsexamples/nft-enumerable/src/contract.rsexamples/nft-royalties/src/contract.rsexamples/nft-sequential-minting/src/contract.rsexamples/rwa/token/src/contract.rspackages/tokens/src/fungible/extensions/allowlist/mod.rspackages/tokens/src/fungible/extensions/blocklist/mod.rspackages/tokens/src/fungible/extensions/burnable/mod.rspackages/tokens/src/fungible/extensions/burnable/storage.rspackages/tokens/src/fungible/extensions/burnable/test.rspackages/tokens/src/fungible/extensions/capped/mod.rspackages/tokens/src/fungible/extensions/capped/test.rspackages/tokens/src/fungible/extensions/combinations/mod.rspackages/tokens/src/fungible/extensions/combinations/storage.rspackages/tokens/src/fungible/extensions/combinations/test.rspackages/tokens/src/fungible/extensions/mod.rspackages/tokens/src/fungible/extensions/total_supply/mod.rspackages/tokens/src/fungible/extensions/total_supply/storage.rspackages/tokens/src/fungible/extensions/total_supply/test.rspackages/tokens/src/fungible/extensions/votes/storage.rspackages/tokens/src/fungible/extensions/votes/test.rspackages/tokens/src/fungible/mod.rspackages/tokens/src/fungible/overrides.rspackages/tokens/src/fungible/storage.rspackages/tokens/src/fungible/test.rspackages/tokens/src/non_fungible/extensions/burnable/mod.rspackages/tokens/src/non_fungible/extensions/combinations/mod.rspackages/tokens/src/non_fungible/extensions/mod.rspackages/tokens/src/non_fungible/mod.rspackages/tokens/src/non_fungible/overrides.rspackages/tokens/src/rwa/mod.rspackages/tokens/src/rwa/storage.rspackages/tokens/src/rwa/test.rspackages/tokens/src/vault/mod.rspackages/tokens/src/vault/storage.rspackages/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
Tracking the total supply is not required by SEP-41 and has a scalability cost: every mint and burn writes a shared storage entry, serializing otherwise independent transactions under parallel execution. The base FungibleToken trait no longer tracks or exposes it. The opt-in total_supply extension provides the FungibleTotalSupply trait and a supply-aware TotalSupply contract type, storing the supply in its own persistent entry so mints and burns only conflict with each other, never with plain transfers. Compose resolves the curated combinations with the allowlist/blocklist policies; the combined contract types stay internal. RWA, Vault and FungibleVotes are inherently supply-aware (votes serves the query from its checkpoints, removing the previous double-tracking). Closes #33 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
f3263ca to
9205bff
Compare
Fixes #560
PR Checklist
@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
Documentation