Add Token Standard V2 allocation state recovery#380
Conversation
…ard-allocation-state
📝 WalkthroughWalkthroughAdds Token Standard V2 allocation-state types, decoding and validation, ACS-based Completed/Pending discovery, contract-ID lookup, public exports, interface-view schema support, and comprehensive unit tests. ChangesAllocation state
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant discoverTokenStandardV2AllocationState
participant CantonLedger
participant AllocationViewDecoder
Caller->>discoverTokenStandardV2AllocationState: Submit allocation request
discoverTokenStandardV2AllocationState->>CantonLedger: Query active AllocationV2 interfaces
CantonLedger-->>discoverTokenStandardV2AllocationState: Return ACS rows
discoverTokenStandardV2AllocationState->>AllocationViewDecoder: Decode and match identities
AllocationViewDecoder-->>discoverTokenStandardV2AllocationState: Completed, Pending, or no match
discoverTokenStandardV2AllocationState-->>Caller: Return state or Unknown
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
…allocation-state # Conflicts: # src/utils/token-standard/v2/allocation.ts # src/utils/token-standard/v2/index.ts # test/unit/token-standard/v2/allocation.test.ts
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/clients/ledger-json-api/schemas/api/interface-view.ts`:
- Line 16: Modernize the schema’s deprecated strict-object declaration by
replacing the `.strict()` usage in the relevant interface schema with Zod 4’s
`z.strictObject()` while preserving all existing fields and validation behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b254ea5d-1e2c-4cfe-b039-0ae6d16aa18c
📒 Files selected for processing (4)
src/clients/ledger-json-api/schemas/api/interface-view.tssrc/utils/token-standard/v2/allocation-state.tstest/unit/schemas/interface-view.test.tstest/unit/token-standard/v2/allocation-state.test.ts
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3bccc22. Configure here.
|
cursor review |
|
@coderabbitai review |
|
Stage 2 on exact head 6bbf3bb: all checks are green including CN Quickstart, GitHub is CLEAN/MERGEABLE, and all five review threads are resolved. Latest-head Copilot was explicitly requested first, followed by Cursor and CodeRabbit; the PR remains unassigned while those reviewers respond. |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6bbf3bb. Configure here.
|
Resetting to draft after latest-head Copilot review: sparse arrays can bypass both string-array validation and equality checks, one interface-view failure message misidentifies instruction views, and current main has advanced into a merge conflict. I am merging current main with a normal merge commit, addressing all three findings with regressions, and rerunning the full gate before requesting fresh reviews. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Merged current main at a70bd54 with normal merge commit d225cf5, preserving both allocation-state recovery and holding-selection exports. Addressed all three latest-head Copilot findings and proactively closed the same sparse-array bypass for transfer-leg and allocation-CID inputs. Local validation passed: TypeScript 7 core/lint, 47 focused tests, targeted ESLint/Prettier, package artifact 5.41 MB / 1,313 files, and diff hygiene. Full unit and fresh CI are now running; the PR remains draft and unassigned. |
|
cursor review |
|
@coderabbitai review |
|
Stage 2 restarted on exact head d225cf5: all checks pass including CN Quickstart, GitHub is CLEAN/MERGEABLE, focused validation is 47/47, full unit validation is 69 suites / 738 tests, and all eight review threads are resolved. Latest-head Copilot was explicitly requested first, followed by Cursor and CodeRabbit; the PR remains unassigned while they respond. |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d225cf5. Configure here.
|
Final readiness sweep on exact head d225cf5: all checks pass, including CN Quickstart; GitHub reports CLEAN/MERGEABLE against main a70bd54; focused validation is 47/47 and the full unit suite is 69 suites / 738 tests; Copilot reviewed 5/5 changed files with no new comments; Cursor found no issues; CodeRabbit completed its latest incremental review; all eight threads are resolved; the worktree is clean. The PR is ready for final human review. It remains unassigned because no standing thumbs-up merge authorization is present. |
Summary
Why
After an allocation submission has an unknown outcome, callers need reusable state recovery without Fairmint-specific database or route logic. The active contract set can prove Completed or Pending, but cannot reconstruct a transient Failed result.
Atomic-settlement callers also need to validate the exact allocation contracts they will submit. Returning CIDs and decoded views from one required
activeAtOffsetsnapshot prevents an off-ledger snapshot from being paired with different contract IDs later.Validation
Exact head
d225cf5:Dependencies
The allocation helpers from PR #374 and holding selection from PR #376 are merged into
main.