Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Test/daml/OpenCapTable/TestValuationReferences.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module OpenCapTable.TestValuationReferences where

import Fairmint.OpenCapTable.OCF.Valuation
import Fairmint.OpenCapTable.Types.Monetary
import qualified Fairmint.OpenCapTable.CapTable as CT
import OpenCapTable.Setup
import OpenCapTable.TestHelpers
import Daml.Script

valuationForStockClass : Text -> Text -> ValuationOcfData
valuationForStockClass valuationId stockClassId = ValuationOcfData with
id = valuationId
effective_date = defaultTestDate
price_per_share = OcfMonetary with amount = 1.0, currency = "USD"
stock_class_id = stockClassId
valuation_type = OcfValuationType409A
comments = []
board_approval_date = None
provider = None
stockholder_approval_date = None

testValuationStockClassCreatedInSameBatchSucceeds = script do
TestOcp{issuer, cap_table} <- setupTestOcp

_ <- submit issuer do
exerciseCmd cap_table CT.UpdateCapTable with
creates =
[ CT.OcfCreateStockClass (defaultStockClass "SC_VALUATION_TARGET")
, CT.OcfCreateValuation (valuationForStockClass "VAL_TARGET_REF" "SC_VALUATION_TARGET")
]
edits = []
deletes = []
pure ()

testValuationMissingStockClassFails = script do
TestOcp{issuer, cap_table} <- setupTestOcp

submitMustFail issuer do
exerciseCmd cap_table CT.UpdateCapTable with
creates = [CT.OcfCreateValuation (valuationForStockClass "VAL_MISSING_TARGET" "SC_MISSING_VALUATION_TARGET")]
edits = []
deletes = []

testValuationEditMissingStockClassFails = script do
TestOcp{issuer, cap_table} <- setupTestOcp
result <- submit issuer do
exerciseCmd cap_table CT.UpdateCapTable with
creates =
[ CT.OcfCreateStockClass (defaultStockClass "SC_VALUATION_EDIT_TARGET")
, CT.OcfCreateValuation (valuationForStockClass "VAL_EDIT_TARGET" "SC_VALUATION_EDIT_TARGET")
]
edits = []
deletes = []

submitMustFail issuer do
exerciseCmd result.updatedCapTableCid CT.UpdateCapTable with
creates = []
edits = [CT.OcfEditValuation (valuationForStockClass "VAL_EDIT_TARGET" "SC_MISSING_VALUATION_EDIT_TARGET")]
deletes = []

testValuationStockClassDeleteCannotLeaveDanglingReference = script do
TestOcp{issuer, cap_table} <- setupTestOcp
result <- submit issuer do
exerciseCmd cap_table CT.UpdateCapTable with
creates =
[ CT.OcfCreateStockClass (defaultStockClass "SC_VALUATION_DELETE_TARGET")
, CT.OcfCreateValuation (valuationForStockClass "VAL_DANGLING_TARGET" "SC_VALUATION_DELETE_TARGET")
]
edits = []
deletes = []

submitMustFail issuer do
exerciseCmd result.updatedCapTableCid CT.UpdateCapTable with
creates = []
edits = []
deletes = [CT.OcfDeleteStockClass "SC_VALUATION_DELETE_TARGET"]
4 changes: 2 additions & 2 deletions dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar
Git LFS file not shown
4 changes: 2 additions & 2 deletions dars/dars.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
]
},
"OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar": {
"sha256": "3659e1d3773ec6768ed3521a627d4e3b06eb45de34767ef878cf19848a3d73ac",
"size": 2502327,
"sha256": "417df118e32d40ebfad6ec43e1a6b3512d6322ddd5c7a6e128bf730e4b7166b3",
"size": 2503261,
"sdkVersion": "3.4.10",
"uploadedAt": "2026-07-07T21:50:59.634Z",
"networks": []
Expand Down
9 changes: 9 additions & 0 deletions scripts/codegen/templates/CapTable.daml.template
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ validateWarrantConversionRightReferences maps =
issuance.issuance_data.exercise_triggers)
(Map.values maps.warrant_issuances)

validateValuationStockClassReferences : CapTableMaps -> Update ()
validateValuationStockClassReferences maps =
mapA_
(\valuationCid -> do
valuation <- fetch valuationCid
validateStockClassReference "Valuation stock class" maps valuation.valuation_data.stock_class_id)
(Map.values maps.valuations)

-- | Get the processing tier for a create operation
getCreateTier : OcfCreateData -> Int
getCreateTier createData = case createData of
Expand Down Expand Up @@ -473,6 +481,7 @@ template CapTable
validateStockClassConversionRightReferences finalMaps
validateConvertibleConversionRightReferences finalMaps
validateWarrantConversionRightReferences finalMaps
validateValuationStockClassReferences finalMaps
validateIssuerAuthorizedShares finalMaps newIssuerCid

-- Create new CapTable with updated maps and potentially new issuer
Expand Down
Loading