-
Notifications
You must be signed in to change notification settings - Fork 0
Enforce OCF reference integrity #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
HardlyDifficult
wants to merge
10
commits into
codex/ocf-stock-class-share-ceiling
from
codex/ocf-reference-integrity
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4e07ce3
feat: enforce OCF reference integrity
HardlyDifficult 167b4b9
Restack reference integrity on authorized share ceilings
HardlyDifficult 9859c94
Merge remote-tracking branch 'origin/codex/ocf-stock-class-share-ceil…
HardlyDifficult cdb3c7f
Merge remote-tracking branch 'origin/codex/ocf-stock-class-share-ceil…
HardlyDifficult 7a7c4be
Merge remote-tracking branch 'origin/codex/ocf-stock-class-share-ceil…
HardlyDifficult ece7511
Restack reference integrity on share ceiling
HardlyDifficult 4175b9e
Restack reference integrity on indexed share ceilings
HardlyDifficult 45c6352
Address reference integrity review feedback
HardlyDifficult 37674c1
Allow equity compensation same-batch reference edits
HardlyDifficult 942fb17
Merge authorized ceiling base into reference integrity
HardlyDifficult File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
Test/daml/OpenCapTable/TestConvertibleConversionRightReferences.daml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| module OpenCapTable.TestConvertibleConversionRightReferences where | ||
|
|
||
| import Fairmint.OpenCapTable.OCF.ConvertibleIssuance | ||
| import Fairmint.OpenCapTable.Types.Conversion | ||
| import Fairmint.OpenCapTable.Types.Monetary | ||
| import qualified Fairmint.OpenCapTable.CapTable as CT | ||
| import OpenCapTable.Setup | ||
| import OpenCapTable.TestHelpers | ||
| import Daml.Script | ||
|
|
||
| convertibleConversionTriggerTo : Optional Text -> OcfConvertibleConversionTrigger | ||
| convertibleConversionTriggerTo stockClassId = OcfConvertibleConversionTrigger with | ||
| conversion_right = OcfConvertibleConversionRight with | ||
| conversion_mechanism = OcfConvMechSAFE (OcfSAFEConversionMechanism with | ||
| capitalization_definition = None | ||
| capitalization_definition_rules = None | ||
| conversion_discount = Some 0.2 | ||
| conversion_mfn = False | ||
| conversion_timing = None | ||
| conversion_valuation_cap = None | ||
| exit_multiple = None) | ||
| converts_to_future_round = None | ||
| converts_to_stock_class_id = stockClassId | ||
| type_ = "CONVERTIBLE_CONVERSION_RIGHT" | ||
| end_date = None | ||
| nickname = None | ||
| start_date = None | ||
| trigger_condition = None | ||
| trigger_date = None | ||
| trigger_description = None | ||
| trigger_id = "TRIGGER-1" | ||
| type_ = OcfTriggerTypeTypeUnspecified | ||
|
|
||
| convertibleIssuanceWithConversionTarget : Text -> Text -> Optional Text -> ConvertibleIssuanceOcfData | ||
| convertibleIssuanceWithConversionTarget issuanceId securityId stockClassId = ConvertibleIssuanceOcfData with | ||
| id = issuanceId | ||
| date = defaultTestDate | ||
| security_id = securityId | ||
| custom_id = "CN-" <> issuanceId | ||
| stakeholder_id = defaultStakeholderId | ||
| board_approval_date = None | ||
| stockholder_approval_date = None | ||
| consideration_text = None | ||
| security_law_exemptions = [] | ||
| investment_amount = OcfMonetary with amount = 100_000.0, currency = "USD" | ||
| convertible_type = OcfConvertibleSafe | ||
| conversion_triggers = [convertibleConversionTriggerTo stockClassId] | ||
| pro_rata = None | ||
| seniority = 1 | ||
| comments = [] | ||
|
|
||
| testConvertibleConversionRightTargetCreatedInSameBatchSucceeds = script do | ||
| TestOcp{issuer, cap_table} <- setupTestOcp | ||
| capTableWithStakeholder <- addDefaultStakeholder issuer cap_table | ||
|
|
||
| _ <- submit issuer do | ||
| exerciseCmd capTableWithStakeholder CT.UpdateCapTable with | ||
| creates = | ||
| [ CT.OcfCreateStockClass (defaultStockClass "SC_CONVERTIBLE_TARGET") | ||
| , CT.OcfCreateConvertibleIssuance (convertibleIssuanceWithConversionTarget "TX_CONVERTIBLE_TARGET_REF" "CONV-TARGET-REF" (Some "SC_CONVERTIBLE_TARGET")) | ||
| ] | ||
| edits = [] | ||
| deletes = [] | ||
| pure () | ||
|
|
||
| testConvertibleConversionRightMissingTargetFails = script do | ||
| TestOcp{issuer, cap_table} <- setupTestOcp | ||
| capTableWithStakeholder <- addDefaultStakeholder issuer cap_table | ||
|
|
||
| submitMustFail issuer do | ||
| exerciseCmd capTableWithStakeholder CT.UpdateCapTable with | ||
| creates = [CT.OcfCreateConvertibleIssuance (convertibleIssuanceWithConversionTarget "TX_CONVERTIBLE_MISSING_TARGET" "CONV-MISSING-TARGET" (Some "SC_MISSING_CONVERTIBLE_TARGET"))] | ||
| edits = [] | ||
| deletes = [] | ||
|
|
||
| testConvertibleConversionRightEditMissingTargetFails = script do | ||
| TestOcp{issuer, cap_table} <- setupTestOcp | ||
| capTableWithStakeholder <- addDefaultStakeholder issuer cap_table | ||
| result <- submit issuer do | ||
| exerciseCmd capTableWithStakeholder CT.UpdateCapTable with | ||
| creates = [CT.OcfCreateConvertibleIssuance (convertibleIssuanceWithConversionTarget "TX_CONVERTIBLE_EDIT_TARGET" "CONV-EDIT-TARGET" None)] | ||
| edits = [] | ||
| deletes = [] | ||
|
|
||
| submitMustFail issuer do | ||
| exerciseCmd result.updatedCapTableCid CT.UpdateCapTable with | ||
| creates = [] | ||
| edits = [CT.OcfEditConvertibleIssuance (convertibleIssuanceWithConversionTarget "TX_CONVERTIBLE_EDIT_TARGET" "CONV-EDIT-TARGET" (Some "SC_MISSING_CONVERTIBLE_EDIT_TARGET"))] | ||
| deletes = [] | ||
|
|
||
| testConvertibleConversionRightTargetDeleteCannotLeaveDanglingReference = script do | ||
| TestOcp{issuer, cap_table} <- setupTestOcp | ||
| capTableWithStakeholder <- addDefaultStakeholder issuer cap_table | ||
| result <- submit issuer do | ||
| exerciseCmd capTableWithStakeholder CT.UpdateCapTable with | ||
| creates = | ||
| [ CT.OcfCreateStockClass (defaultStockClass "SC_CONVERTIBLE_DELETE_TARGET") | ||
| , CT.OcfCreateConvertibleIssuance (convertibleIssuanceWithConversionTarget "TX_CONVERTIBLE_DANGLING_TARGET" "CONV-DANGLING-TARGET" (Some "SC_CONVERTIBLE_DELETE_TARGET")) | ||
| ] | ||
| edits = [] | ||
| deletes = [] | ||
|
|
||
| submitMustFail issuer do | ||
| exerciseCmd result.updatedCapTableCid CT.UpdateCapTable with | ||
| creates = [] | ||
| edits = [] | ||
| deletes = [CT.OcfDeleteStockClass "SC_CONVERTIBLE_DELETE_TARGET"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Consider adding a positive edit-success test.
Only the failure path for editing a conversion target is covered (
testConvertibleConversionRightEditMissingTargetFails). There's no test confirming that editing a convertible issuance'sconverts_to_stock_class_idto a valid existing stock class succeeds, which is the complementary happy-path for the edit validation wired intoprocessEdit.🧪 Example addition
🤖 Prompt for AI Agents