#95 Change split logic to return splits info only#100
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the token split flow so that the split operation returns split metadata (burn predicate/commitment + proofs) rather than mint commitments, and updates mint-reason verification to accept a RootTrustBase.
Changes:
- Refactor split logic into
TokenSplitBuilder.split(...)returning aTokenSplitcontaining burn predicate/commitment and per-new-token split proofs (plus serialization helpers). - Update
IMintTransactionReason.verify(...)and mint transaction verification to passtrustBase, and strengthenSplitMintReasonverification accordingly. - Update tests/docs and bump dev dependencies.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/token/CommonTestFlow.ts | Updates split test flow to use TokenSplitBuilder.split(...) output (commitment + proofs) and then mint manually. |
| src/transaction/split/TokenSplitBuilder.ts | Major split refactor: introduces exported TokenSplit, proof map wrappers, and JSON/CBOR serialization; exposes new static split(...) API. |
| src/transaction/TransferCommitment.ts | Exports ITransferCommitmentJson for reuse in new split JSON types. |
| src/transaction/MintTransaction.ts | Passes trustBase into mint-reason verification. |
| src/transaction/IMintTransactionReason.ts | Updates mint-reason verification signature to accept RootTrustBase. |
| src/token/fungible/SplitMintReason.ts | Updates verify(...) signature and adds token verification step using trustBase. |
| src/token/Token.ts | Uses internal backing fields (_transactions, _nametagTokens) in verification/stringification paths. |
| package.json | Dev dependency version bumps (eslint/tooling/testcontainers/etc.). |
| package-lock.json | Lockfile updates corresponding to dev dependency bumps. |
| README.md | Updates split example to match new TokenSplitBuilder.split(...) API and manual minting flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export class TokenSplit { | ||
| public constructor( | ||
| private readonly token: Token<IMintTransactionReason>, | ||
| private readonly aggregationRoot: SparseMerkleTreeRootNode, | ||
| private readonly coinRoots: Map<string, SparseMerkleSumTreeRootNode>, | ||
| private readonly tokens: TokenRequest[], | ||
| public readonly predicate: BurnPredicate, | ||
| public readonly commitment: TransferCommitment, | ||
| public readonly proofs: ProofMap, | ||
| public readonly token: Token<IMintTransactionReason>, |
There was a problem hiding this comment.
TokenSplit is exported but its public proofs property exposes the non-exported ProofMap type (and entries() returns non-exported ProofMapEntry). This leaks private types into the public API and makes the generated .d.ts harder to consume. Consider exporting these types or changing the public surface to standard types (e.g., ReadonlyMap<string, SplitMintReasonProof[]> / ReadonlyArray<...>) and keeping the internal wrappers private.
No description provided.