diff --git a/Test/daml/OpenCapTable/TestStockPlanReferences.daml b/Test/daml/OpenCapTable/TestStockPlanReferences.daml new file mode 100644 index 00000000..8f151b69 --- /dev/null +++ b/Test/daml/OpenCapTable/TestStockPlanReferences.daml @@ -0,0 +1,45 @@ +module OpenCapTable.TestStockPlanReferences where + +import qualified Fairmint.OpenCapTable.CapTable as CT +import OpenCapTable.Setup +import OpenCapTable.TestHelpers +import Daml.Script + +testStockPlan_MissingStockClassReferenceFails = script do + TestOcp{issuer, cap_table} <- setupTestOcp + + submitMustFail issuer do + exerciseCmd cap_table CT.UpdateCapTable with + creates = [CT.OcfCreateStockPlan (defaultStockPlan "PLAN_MISSING_CLASS" "SC_MISSING")] + edits = [] + deletes = [] + +testStockPlan_StockClassCreatedInSameBatchSucceeds = script do + TestOcp{issuer, cap_table} <- setupTestOcp + + _ <- submit issuer do + exerciseCmd cap_table CT.UpdateCapTable with + creates = + [ CT.OcfCreateStockClass (defaultStockClass "SC_VALID") + , CT.OcfCreateStockPlan (defaultStockPlan "PLAN_VALID" "SC_VALID") + ] + edits = [] + deletes = [] + pure () + +testStockPlan_EditMissingStockClassReferenceFails = script do + TestOcp{issuer, cap_table} <- setupTestOcp + (capTableCid, classId) <- setupStockClass issuer cap_table + let plan = defaultStockPlan "PLAN_EDIT_CLASS" classId + createResult <- submit issuer do + exerciseCmd capTableCid CT.UpdateCapTable with + creates = [CT.OcfCreateStockPlan plan] + edits = [] + deletes = [] + let editedPlan = plan with stock_class_ids = ["SC_MISSING_ON_EDIT"] + + submitMustFail issuer do + exerciseCmd createResult.updatedCapTableCid CT.UpdateCapTable with + creates = [] + edits = [CT.OcfEditStockPlan editedPlan] + deletes = [] diff --git a/Test/daml/OpenCapTable/TestStockPlanReturnToPool.daml b/Test/daml/OpenCapTable/TestStockPlanReturnToPool.daml index 3dc9004d..53da24bb 100644 --- a/Test/daml/OpenCapTable/TestStockPlanReturnToPool.daml +++ b/Test/daml/OpenCapTable/TestStockPlanReturnToPool.daml @@ -4,6 +4,7 @@ import Fairmint.OpenCapTable.OCF.StockPlan import Fairmint.OpenCapTable.OCF.StockPlanReturnToPool import qualified Fairmint.OpenCapTable.CapTable as CT import OpenCapTable.Setup +import OpenCapTable.TestHelpers (addDefaultStockClass) import qualified DA.Date as DA import DA.Date (Month(..)) import qualified DA.Time as DT @@ -13,8 +14,9 @@ import Daml.Script -- Test: Create and archive return to pool (termination scenario) testCreateAndArchiveStockPlanReturnToPool = script do TestOcp{system_operator, issuer, ctx, cap_table} <- setupTestOcp + capTableCid <- addDefaultStockClass issuer cap_table result <- submit issuer do - exerciseCmd cap_table CT.UpdateCapTable with + exerciseCmd capTableCid CT.UpdateCapTable with creates = [CT.OcfCreateStockPlan StockPlanOcfData with id = "PLAN_2021" plan_name = "2021 Equity Incentive Plan" @@ -45,8 +47,9 @@ testCreateAndArchiveStockPlanReturnToPool = script do -- Test: Create and archive with Archive choice (expiration scenario) testCreateAndArchiveStockPlanReturnToPoolExpiration = script do TestOcp{system_operator, issuer, ctx, cap_table} <- setupTestOcp + capTableCid <- addDefaultStockClass issuer cap_table result <- submit issuer do - exerciseCmd cap_table CT.UpdateCapTable with + exerciseCmd capTableCid CT.UpdateCapTable with creates = [CT.OcfCreateStockPlan StockPlanOcfData with id = "PLAN_2015" plan_name = "2015 Stock Option Plan" diff --git a/dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar b/dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar index db9f66d0..87a68c14 100644 --- a/dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar +++ b/dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f77df928bb56c75578fc8cf35ca0853aca80d8ae61e6d533f5578bd54c48b6f9 -size 2465540 +oid sha256:2afe248b351f9b4e7b84bf2b23d6c5d8d20308126de6c694ab95d21490b0d82b +size 2466418 diff --git a/dars/dars.lock b/dars/dars.lock index a41a1d8a..01e6f584 100644 --- a/dars/dars.lock +++ b/dars/dars.lock @@ -12,8 +12,8 @@ ] }, "OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar": { - "sha256": "f77df928bb56c75578fc8cf35ca0853aca80d8ae61e6d533f5578bd54c48b6f9", - "size": 2465540, + "sha256": "2afe248b351f9b4e7b84bf2b23d6c5d8d20308126de6c694ab95d21490b0d82b", + "size": 2466418, "sdkVersion": "3.4.10", "uploadedAt": "2026-07-07T21:50:59.634Z", "networks": [] diff --git a/scripts/codegen/captable-config.yaml b/scripts/codegen/captable-config.yaml index 70f5f758..73b0cfb9 100644 --- a/scripts/codegen/captable-config.yaml +++ b/scripts/codegen/captable-config.yaml @@ -75,6 +75,9 @@ tiers: # that the security exists in the correct issuance type. This ensures type safety - a # StockTransfer can only reference a stock security, not a warrant security. validations: + # Stock plans - validate referenced stock classes exist + StockPlan: ['stock_class_ids[]:stock_classes'] + # Issuances - validate stakeholder exists StockIssuance: [