[M1: Audit 2: L-04]: CIP112: Pass consumed holdings to createHolding so consumer fields survive re-creation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- blockchain
Research direction
Start with packages/token/token-cip112-utils/daml/OpenZeppelin/Token/Cip112/Utils/Holding.daml and its createHolding and consumeHolding operations, then trace the listed re-creation paths in Transfer.daml and Allocation.daml. Read the token-cip112-utils README.md for the documentation requirements. Done means consumed holding fields survive across every specified workflow, mint uses closure defaults, and the docs explain reset behavior and where in-flight state belongs; add the requested test-package coverage.
Written by the indexing model from the issue text.
Description
Addresses L-04
Problem
HoldingOps.createHolding receives only a standard HoldingView. Every workflow path that consumes a holding and creates a replacement builds the new contract from the closure's defaults, so consumer template fields (a freeze flag, a tag, a tier, an issue timestamp) reset on every re-creation. The re-creation paths are:
- transfers: sender change, locked funding, surplus, receiver payout, and returned funds on reject, withdraw and expire
- allocations: lock, change, reserve and payout
holdingOwnerUnlockImplandunlockHoldings
A consumer can't carry state across these paths, and the HoldingOps documentation doesn't warn that the state is lost. The default TokenHolding has no extra fields and isn't affected.
The example's compliance freeze is tracked separately in #82, which moves the freeze to a per-account status contract.
Changes
Code:
createHoldingshould receive the holdings consumed to produce the new one: their template values, or at least their views. Each workflow path passes its consumed inputs, a mint passes none, and the consumer's closure decides which fields to carry over.consumeHoldingshould return whatevercreateHoldingneeds, so the workflows can pass it along without fetching the holdings again.- Update the
TokenHoldingops to the new signature. Its behaviour doesn't change.
Documentation:
- The
HoldingOpsdoc comment and thetoken-cip112-utilsREADME.mdshould state which consumed holdings each path passes tocreateHolding, and that any field the closure doesn't derive from them resets on re-creation. - They should also state that state which must hold while funds are in flight belongs on a separate per-account contract, not on the holding: the spend hook refuses such holdings, so no re-creation path consumes them.
Tests:
- In a test package, add a holding template with an extra field and a
createHoldingthat copies the field from the consumed holdings. Check that the field is still on the holding a workflow returns, for every path:- Transfers: sender change, then reject, withdraw and expire of the pending transfer. The returned holding should still carry the field from the original holding, which shows the locked holding carried it through the pending period.
- Allocations: change and the locked holding at allocation time, then cancel, withdraw and expire of the pending allocation, and the reserve on settlement.
- Owner unlock of an expired locked holding.
- Check that a mint, which consumes nothing, creates the holding with the closure's defaults.
- Dominant language
- Haskell
- Stars
- 5
- Forks
- 0
- Avg merge
- 1d 36m
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenZeppelin/canton-contracts
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/canton-contracts#92 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
OpenZeppelin/canton-contracts#88 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/canton-contracts#86 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
OpenZeppelin/canton-contracts#96 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
OpenZeppelin/canton-contracts#95 ·
Maintainers usually reply within 1 day
All issues in OpenZeppelin/canton-contracts
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
IntersectMBO/cardano-ledger#6276 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
hasura/graphql-engine#10954 ·
Maintainers usually reply within 1 day