feat(dapp): reserve only the granted amount when a grant is created - #192
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🔵 Needs a closer look
It reworks critical ledger/state-reconciliation logic and relies on a breaking upgrade to an external vendored DAR whose split semantics and tokenCid field cannot be verified from the diff, warranting human review.
Pull request overview
This PR changes the vesting dApp so that creating a grant reserves only the granted amount rather than the whole holdings it names. This is possible because the upgraded canton-vesting-forge v0.2.0 DAR makes VestingFactory_CreateVesting split the funder's inputs itself (transferring exactly the grant amount into one holding and returning the change in the same transaction), which is why creating a grant now also discloses the InstrumentConfig. The frontend follows suit: a pending grant now names a single reserved holding (tokenCid), disclosure blobs are read back and reconciled after the write, and pending grants gain an instrument filter now that the proposal carries admin/instrumentId.
Changes:
- Backend now reserves the single split-off holding per grant (
reservedToken), passesconfigCidtobuildCreateVestingCommand, and reconciles funder disclosure blobs inlocalStorageafter the submit (with a bounded read-miss guard so a permanently-missing holding stops costing a read). acceptandfreeTokens/balanceOfupdated to the one-holding model; pending grants are now filtered by instrument like grants/claims.- Vendored
vesting.darmoved tov0.2.0, withPROVENANCE.mddocumenting theNOT_VALID_UPGRADE_PACKAGEreset requirement, and user copy/architecture docs updated to the "reserve exactly this amount" behavior.
File summaries
| File | Description |
|---|---|
vendor/PROVENANCE.md |
Bumps vendored vesting.dar to v0.2.0 and records why an existing ledger must be reset before upload. |
dapp/frontend/src/components/CreateGrant/index.tsx |
Updates the amount-field copy to reflect that only the granted amount is reserved. |
dapp/frontend/src/backend/VestingBackend.ts |
Replaces pledgedTokens with reservedToken (single holding), adds fundedBy, updates selectHoldings rationale. |
dapp/frontend/src/backend/VestingBackend.test.ts |
Adjusts tests to the single reserved-token model. |
dapp/frontend/src/backend/LedgerBackend.ts |
Adds disclosure-blob reconciliation (storeFunding/reconcileFunding/miss-limit), returns disclosed set from submitWithConfig, reworks createVesting/accept/freeTokens, filters pending grants by instrument. |
dapp/frontend/src/backend/LedgerBackend.test.ts |
Rewrites the harness to model the factory split and adds coverage for reconciliation, miss-limit, overlap, and instrument filtering. |
dapp/frontend/src/backend/commands.ts |
Adds configCid to the VestingFactory_CreateVesting choice arguments. |
dapp/frontend/src/backend/commands.test.ts |
Adds configCid assertions to the command-builder test. |
dapp/frontend/architecture.md |
Rewrites the "one approval" section to describe the factory split, reconciliation, and instrument filtering. |
Review details
- Files reviewed: 8/10 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Closes #180
VestingFactory_CreateVestingnow splits the funder's inputs itself, so a grant reserves itsown amount instead of every holding it names. Consumes canton-vesting-forge
v0.2.0.Changes
vesting.darmoves tov0.2.0Deviations
adminandinstrumentIdfields made possiblevendor/PROVENANCE.mdrecords why an existing ledger refuses the new packageAcceptance criteria
Test plan
Automated tests
pnpm installpnpm -C dapp/frontend testManual verification
./scripts/dev-stack.sh down, then( cd .canton-localnet && ../node_modules/.bin/canton-barebones reset )./scripts/dev-stack.sh upand open http://localhost:3012 with a CIP-0103 walletBreaking changes
A ledger that already carries
vesting0.0.1 rejects the new DAR withNOT_VALID_UPGRADE_PACKAGE.Reset the LocalNet before
up, as step 1 of the manual verification does.Checklist
Screenshots
To be added before review.