@open-captable-protocol/canton 0.2.222 → 0.2.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/OpenCapTable/capTable/damlToOcf.d.ts +3 -4
- package/dist/functions/OpenCapTable/capTable/damlToOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/capTable/damlToOcf.js +55 -2
- package/dist/functions/OpenCapTable/capTable/damlToOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/convertibleCancellation/createConvertibleCancellation.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/convertibleCancellation/createConvertibleCancellation.js +1 -0
- package/dist/functions/OpenCapTable/convertibleCancellation/createConvertibleCancellation.js.map +1 -1
- package/dist/functions/OpenCapTable/convertibleCancellation/damlToOcf.d.ts +9 -0
- package/dist/functions/OpenCapTable/convertibleCancellation/damlToOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/convertibleCancellation/damlToOcf.js +7 -0
- package/dist/functions/OpenCapTable/convertibleCancellation/damlToOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/convertibleIssuance/getConvertibleIssuanceAsOcf.d.ts +3 -1
- package/dist/functions/OpenCapTable/convertibleIssuance/getConvertibleIssuanceAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/convertibleIssuance/getConvertibleIssuanceAsOcf.js +396 -405
- package/dist/functions/OpenCapTable/convertibleIssuance/getConvertibleIssuanceAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/document/getDocumentAsOcf.d.ts +2 -0
- package/dist/functions/OpenCapTable/document/getDocumentAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/document/getDocumentAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/document/getDocumentAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationExercise/getEquityCompensationExerciseAsOcf.d.ts +9 -12
- package/dist/functions/OpenCapTable/equityCompensationExercise/getEquityCompensationExerciseAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationExercise/getEquityCompensationExerciseAsOcf.js +48 -19
- package/dist/functions/OpenCapTable/equityCompensationExercise/getEquityCompensationExerciseAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationExercise/index.d.ts +1 -1
- package/dist/functions/OpenCapTable/equityCompensationExercise/index.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationExercise/index.js +4 -15
- package/dist/functions/OpenCapTable/equityCompensationExercise/index.js.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationIssuance/getEquityCompensationIssuanceAsOcf.d.ts +9 -39
- package/dist/functions/OpenCapTable/equityCompensationIssuance/getEquityCompensationIssuanceAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/equityCompensationIssuance/getEquityCompensationIssuanceAsOcf.js +60 -69
- package/dist/functions/OpenCapTable/equityCompensationIssuance/getEquityCompensationIssuanceAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/issuer/getIssuerAsOcf.d.ts +3 -0
- package/dist/functions/OpenCapTable/issuer/getIssuerAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/issuer/getIssuerAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/issuer/getIssuerAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/issuerAuthorizedSharesAdjustment/getIssuerAuthorizedSharesAdjustmentAsOcf.d.ts +9 -11
- package/dist/functions/OpenCapTable/issuerAuthorizedSharesAdjustment/getIssuerAuthorizedSharesAdjustmentAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/issuerAuthorizedSharesAdjustment/getIssuerAuthorizedSharesAdjustmentAsOcf.js +27 -15
- package/dist/functions/OpenCapTable/issuerAuthorizedSharesAdjustment/getIssuerAuthorizedSharesAdjustmentAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.d.ts +2 -0
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockClass/getStockClassAsOcf.d.ts +24 -1
- package/dist/functions/OpenCapTable/stockClass/getStockClassAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockClass/getStockClassAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/stockClass/getStockClassAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockClassAuthorizedSharesAdjustment/getStockClassAuthorizedSharesAdjustmentAsOcf.d.ts +7 -0
- package/dist/functions/OpenCapTable/stockClassAuthorizedSharesAdjustment/getStockClassAuthorizedSharesAdjustmentAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockClassAuthorizedSharesAdjustment/getStockClassAuthorizedSharesAdjustmentAsOcf.js +27 -13
- package/dist/functions/OpenCapTable/stockClassAuthorizedSharesAdjustment/getStockClassAuthorizedSharesAdjustmentAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockIssuance/getStockIssuanceAsOcf.d.ts +2 -0
- package/dist/functions/OpenCapTable/stockIssuance/getStockIssuanceAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockIssuance/getStockIssuanceAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/stockIssuance/getStockIssuanceAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockLegendTemplate/getStockLegendTemplateAsOcf.d.ts +3 -0
- package/dist/functions/OpenCapTable/stockLegendTemplate/getStockLegendTemplateAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockLegendTemplate/getStockLegendTemplateAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/stockLegendTemplate/getStockLegendTemplateAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockPlan/getStockPlanAsOcf.d.ts +2 -0
- package/dist/functions/OpenCapTable/stockPlan/getStockPlanAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockPlan/getStockPlanAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/stockPlan/getStockPlanAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stockPlanPoolAdjustment/getStockPlanPoolAdjustmentAsOcf.d.ts +13 -11
- package/dist/functions/OpenCapTable/stockPlanPoolAdjustment/getStockPlanPoolAdjustmentAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockPlanPoolAdjustment/getStockPlanPoolAdjustmentAsOcf.js +23 -12
- package/dist/functions/OpenCapTable/stockPlanPoolAdjustment/getStockPlanPoolAdjustmentAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.d.ts +2 -0
- package/dist/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.js +1 -0
- package/dist/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/damlToOcf.d.ts +3 -16
- package/dist/functions/OpenCapTable/warrantExercise/damlToOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/damlToOcf.js +35 -5
- package/dist/functions/OpenCapTable/warrantExercise/damlToOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/getWarrantExerciseAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/getWarrantExerciseAsOcf.js +6 -29
- package/dist/functions/OpenCapTable/warrantExercise/getWarrantExerciseAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/warrantExerciseDataToDaml.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/warrantExercise/warrantExerciseDataToDaml.js +7 -0
- package/dist/functions/OpenCapTable/warrantExercise/warrantExerciseDataToDaml.js.map +1 -1
- package/dist/functions/OpenCapTable/warrantIssuance/getWarrantIssuanceAsOcf.d.ts +9 -79
- package/dist/functions/OpenCapTable/warrantIssuance/getWarrantIssuanceAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/warrantIssuance/getWarrantIssuanceAsOcf.js +177 -205
- package/dist/functions/OpenCapTable/warrantIssuance/getWarrantIssuanceAsOcf.js.map +1 -1
- package/dist/types/native.d.ts +4 -0
- package/dist/types/native.d.ts.map +1 -1
- package/dist/utils/cantonOcfExtractor.js +2 -2
- package/dist/utils/cantonOcfExtractor.js.map +1 -1
- package/dist/utils/typeConversions.d.ts +20 -1
- package/dist/utils/typeConversions.d.ts.map +1 -1
- package/dist/utils/typeConversions.js +62 -0
- package/dist/utils/typeConversions.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,428 +1,391 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.damlConvertibleIssuanceDataToNative = damlConvertibleIssuanceDataToNative;
|
|
3
4
|
exports.getConvertibleIssuanceAsOcf = getConvertibleIssuanceAsOcf;
|
|
4
5
|
const errors_1 = require("../../../errors");
|
|
5
6
|
const typeConversions_1 = require("../../../utils/typeConversions");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const d = arg.issuance_data;
|
|
24
|
-
const typeMap = {
|
|
25
|
-
OcfConvertibleNote: 'NOTE',
|
|
26
|
-
OcfConvertibleSafe: 'SAFE',
|
|
27
|
-
OcfConvertibleSecurity: 'SECURITY',
|
|
28
|
-
};
|
|
29
|
-
const convertTriggers = (ts, convertibleType, issuanceId) => {
|
|
30
|
-
if (!Array.isArray(ts))
|
|
31
|
-
return [];
|
|
32
|
-
const mapTagToType = (tag) => {
|
|
33
|
-
if (tag === 'OcfTriggerTypeTypeAutomaticOnDate')
|
|
34
|
-
return 'AUTOMATIC_ON_DATE';
|
|
35
|
-
if (tag === 'OcfTriggerTypeTypeElectiveInRange')
|
|
36
|
-
return 'ELECTIVE_IN_RANGE';
|
|
37
|
-
if (tag === 'OcfTriggerTypeTypeElectiveOnCondition')
|
|
38
|
-
return 'ELECTIVE_ON_CONDITION';
|
|
39
|
-
if (tag === 'OcfTriggerTypeTypeElectiveAtWill')
|
|
40
|
-
return 'ELECTIVE_AT_WILL';
|
|
41
|
-
if (tag === 'OcfTriggerTypeTypeUnspecified')
|
|
42
|
-
return 'UNSPECIFIED';
|
|
43
|
-
return 'AUTOMATIC_ON_CONDITION';
|
|
7
|
+
const typeMap = {
|
|
8
|
+
OcfConvertibleNote: 'NOTE',
|
|
9
|
+
OcfConvertibleSafe: 'SAFE',
|
|
10
|
+
OcfConvertibleSecurity: 'SECURITY',
|
|
11
|
+
};
|
|
12
|
+
const convertTriggers = (ts, issuanceId) => {
|
|
13
|
+
if (!Array.isArray(ts))
|
|
14
|
+
return [];
|
|
15
|
+
const mapMechanism = (m) => {
|
|
16
|
+
// Handle both string enum and DAML variant { tag, value }
|
|
17
|
+
const mapTiming = (t) => {
|
|
18
|
+
const s = (0, typeConversions_1.safeString)(t);
|
|
19
|
+
if (s.endsWith('PreMoney'))
|
|
20
|
+
return 'PRE_MONEY';
|
|
21
|
+
if (s.endsWith('PostMoney'))
|
|
22
|
+
return 'POST_MONEY';
|
|
23
|
+
return undefined;
|
|
44
24
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (typeof monObj.amount !== 'string' && typeof monObj.amount !== 'number') {
|
|
58
|
-
throw new errors_1.OcpValidationError('monetary.amount', `Must be string or number, got ${typeof monObj.amount}`, {
|
|
59
|
-
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
60
|
-
expectedType: 'string | number',
|
|
61
|
-
receivedValue: monObj.amount,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
// Validate currency exists and is string
|
|
65
|
-
if (typeof monObj.currency !== 'string' || !monObj.currency) {
|
|
66
|
-
throw new errors_1.OcpValidationError('monetary.currency', 'Required field must be a non-empty string', {
|
|
67
|
-
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
68
|
-
expectedType: 'string',
|
|
69
|
-
receivedValue: monObj.currency,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const amount = (0, typeConversions_1.normalizeNumericString)(typeof monObj.amount === 'number' ? monObj.amount.toString() : monObj.amount);
|
|
73
|
-
return {
|
|
74
|
-
amount,
|
|
75
|
-
currency: monObj.currency,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const mapTiming = (t) => {
|
|
79
|
-
const s = (0, typeConversions_1.safeString)(t);
|
|
80
|
-
if (s.endsWith('PreMoney'))
|
|
81
|
-
return 'PRE_MONEY';
|
|
82
|
-
if (s.endsWith('PostMoney'))
|
|
83
|
-
return 'POST_MONEY';
|
|
84
|
-
return undefined;
|
|
85
|
-
};
|
|
86
|
-
if (typeof m === 'string') {
|
|
87
|
-
throw new errors_1.OcpParseError(`conversion_mechanism missing variant value (got tag '${m}')`, {
|
|
88
|
-
source: 'conversionRight.conversion_mechanism',
|
|
89
|
-
code: errors_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
25
|
+
if (typeof m === 'string') {
|
|
26
|
+
throw new errors_1.OcpParseError(`conversion_mechanism missing variant value (got tag '${m}')`, {
|
|
27
|
+
source: 'conversionRight.conversion_mechanism',
|
|
28
|
+
code: errors_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (m && typeof m === 'object') {
|
|
32
|
+
const tag = m.tag;
|
|
33
|
+
const value = m.value;
|
|
34
|
+
if (!tag || !value) {
|
|
35
|
+
throw new errors_1.OcpValidationError('conversion_mechanism', 'Tag and value are required', {
|
|
36
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
90
37
|
});
|
|
91
38
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
: value.
|
|
110
|
-
}
|
|
111
|
-
: {}),
|
|
112
|
-
...(value.conversion_valuation_cap
|
|
113
|
-
? {
|
|
114
|
-
conversion_valuation_cap: mapMonetary(value.conversion_valuation_cap) ?? {
|
|
115
|
-
amount: '',
|
|
116
|
-
currency: '',
|
|
117
|
-
},
|
|
118
|
-
}
|
|
119
|
-
: {}),
|
|
120
|
-
...(value.conversion_timing ? { conversion_timing: mapTiming(value.conversion_timing) } : {}),
|
|
121
|
-
...(value.capitalization_definition
|
|
122
|
-
? { capitalization_definition: value.capitalization_definition }
|
|
123
|
-
: {}),
|
|
124
|
-
...(value.capitalization_definition_rules
|
|
125
|
-
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
126
|
-
: {}),
|
|
127
|
-
...(value.exit_multiple
|
|
128
|
-
? {
|
|
129
|
-
exit_multiple: {
|
|
130
|
-
numerator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.numerator)),
|
|
131
|
-
denominator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.denominator)),
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
: {}),
|
|
135
|
-
};
|
|
136
|
-
return mech;
|
|
137
|
-
}
|
|
138
|
-
case 'OcfConvMechPercentCapitalization': {
|
|
139
|
-
const mech = {
|
|
140
|
-
type: 'FIXED_PERCENT_OF_CAPITALIZATION_CONVERSION',
|
|
141
|
-
converts_to_percent: (0, typeConversions_1.normalizeNumericString)(typeof value.converts_to_percent === 'number'
|
|
142
|
-
? value.converts_to_percent.toString()
|
|
143
|
-
: (() => {
|
|
144
|
-
if (typeof value.converts_to_percent !== 'string') {
|
|
145
|
-
throw new errors_1.OcpValidationError('conversion_mechanism.converts_to_percent', `Must be string or number, got ${typeof value.converts_to_percent}`, {
|
|
146
|
-
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
147
|
-
expectedType: 'string | number',
|
|
148
|
-
receivedValue: value.converts_to_percent,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return value.converts_to_percent;
|
|
152
|
-
})()),
|
|
153
|
-
...(value.capitalization_definition
|
|
154
|
-
? { capitalization_definition: value.capitalization_definition }
|
|
155
|
-
: {}),
|
|
156
|
-
...(value.capitalization_definition_rules
|
|
157
|
-
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
158
|
-
: {}),
|
|
159
|
-
};
|
|
160
|
-
return mech;
|
|
161
|
-
}
|
|
162
|
-
case 'OcfConvMechFixedAmount': {
|
|
163
|
-
const mech = {
|
|
164
|
-
type: 'FIXED_AMOUNT_CONVERSION',
|
|
165
|
-
converts_to_quantity: (0, typeConversions_1.normalizeNumericString)(typeof value.converts_to_quantity === 'number'
|
|
166
|
-
? value.converts_to_quantity.toString()
|
|
167
|
-
: (() => {
|
|
168
|
-
if (typeof value.converts_to_quantity !== 'string') {
|
|
169
|
-
throw new errors_1.OcpValidationError('conversion_mechanism.converts_to_quantity', `Must be string or number, got ${typeof value.converts_to_quantity}`, {
|
|
170
|
-
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
171
|
-
expectedType: 'string | number',
|
|
172
|
-
receivedValue: value.converts_to_quantity,
|
|
173
|
-
});
|
|
39
|
+
switch (tag) {
|
|
40
|
+
case 'OcfConvMechSAFE': {
|
|
41
|
+
const mech = {
|
|
42
|
+
type: 'SAFE_CONVERSION',
|
|
43
|
+
conversion_mfn: Boolean(value.conversion_mfn),
|
|
44
|
+
...(typeof value.conversion_discount === 'number' || typeof value.conversion_discount === 'string'
|
|
45
|
+
? {
|
|
46
|
+
conversion_discount: (0, typeConversions_1.normalizeNumericString)(typeof value.conversion_discount === 'number'
|
|
47
|
+
? value.conversion_discount.toString()
|
|
48
|
+
: value.conversion_discount),
|
|
49
|
+
}
|
|
50
|
+
: {}),
|
|
51
|
+
...(value.conversion_valuation_cap
|
|
52
|
+
? {
|
|
53
|
+
conversion_valuation_cap: (() => {
|
|
54
|
+
const monetary = (0, typeConversions_1.damlMonetaryToNativeWithValidation)(value.conversion_valuation_cap);
|
|
55
|
+
if (!monetary) {
|
|
56
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.conversion_valuation_cap', 'Invalid monetary value for conversion_valuation_cap', { code: errors_1.OcpErrorCodes.INVALID_TYPE, receivedValue: value.conversion_valuation_cap });
|
|
174
57
|
}
|
|
175
|
-
return
|
|
176
|
-
})()
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
type: 'SHARE_PRICE_BASED_CONVERSION',
|
|
204
|
-
description: value.description,
|
|
205
|
-
discount: Boolean(value.discount),
|
|
206
|
-
...(value.discount_percentage !== undefined && value.discount_percentage !== null
|
|
207
|
-
? {
|
|
208
|
-
discount_percentage: (0, typeConversions_1.normalizeNumericString)(typeof value.discount_percentage === 'number'
|
|
209
|
-
? value.discount_percentage.toString()
|
|
210
|
-
: typeof value.discount_percentage === 'string'
|
|
211
|
-
? value.discount_percentage
|
|
212
|
-
: (() => {
|
|
213
|
-
throw new errors_1.OcpValidationError('conversion_mechanism.discount_percentage', `Must be string or number, got ${typeof value.discount_percentage}`, {
|
|
214
|
-
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
215
|
-
expectedType: 'string | number',
|
|
216
|
-
receivedValue: value.discount_percentage,
|
|
217
|
-
});
|
|
218
|
-
})()),
|
|
219
|
-
}
|
|
220
|
-
: {}),
|
|
221
|
-
...(value.discount_amount
|
|
222
|
-
? {
|
|
223
|
-
discount_amount: mapMonetary(value.discount_amount) ?? {
|
|
224
|
-
amount: '',
|
|
225
|
-
currency: '',
|
|
226
|
-
},
|
|
227
|
-
}
|
|
228
|
-
: {}),
|
|
229
|
-
};
|
|
230
|
-
return mech;
|
|
231
|
-
}
|
|
232
|
-
case 'OcfConvMechNote': {
|
|
233
|
-
const interest_rates = Array.isArray(value.interest_rates)
|
|
234
|
-
? value.interest_rates.map((ir) => {
|
|
235
|
-
const irObj = ir;
|
|
236
|
-
// Validate interest rate
|
|
237
|
-
if (irObj.rate === undefined || irObj.rate === null) {
|
|
238
|
-
throw new errors_1.OcpValidationError('interest_rate.rate', 'Required field is missing', {
|
|
239
|
-
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (typeof irObj.rate !== 'string' && typeof irObj.rate !== 'number') {
|
|
243
|
-
throw new errors_1.OcpValidationError('interest_rate.rate', `Must be string or number, got ${typeof irObj.rate}`, {
|
|
58
|
+
return monetary;
|
|
59
|
+
})(),
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
...(value.conversion_timing ? { conversion_timing: mapTiming(value.conversion_timing) } : {}),
|
|
63
|
+
...(value.capitalization_definition ? { capitalization_definition: value.capitalization_definition } : {}),
|
|
64
|
+
...(value.capitalization_definition_rules
|
|
65
|
+
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
66
|
+
: {}),
|
|
67
|
+
...(value.exit_multiple
|
|
68
|
+
? {
|
|
69
|
+
exit_multiple: {
|
|
70
|
+
numerator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.numerator)),
|
|
71
|
+
denominator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.denominator)),
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
};
|
|
76
|
+
return mech;
|
|
77
|
+
}
|
|
78
|
+
case 'OcfConvMechPercentCapitalization': {
|
|
79
|
+
const mech = {
|
|
80
|
+
type: 'FIXED_PERCENT_OF_CAPITALIZATION_CONVERSION',
|
|
81
|
+
converts_to_percent: (0, typeConversions_1.normalizeNumericString)(typeof value.converts_to_percent === 'number'
|
|
82
|
+
? value.converts_to_percent.toString()
|
|
83
|
+
: (() => {
|
|
84
|
+
if (typeof value.converts_to_percent !== 'string') {
|
|
85
|
+
throw new errors_1.OcpValidationError('conversion_mechanism.converts_to_percent', `Must be string or number, got ${typeof value.converts_to_percent}`, {
|
|
244
86
|
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
245
87
|
expectedType: 'string | number',
|
|
246
|
-
receivedValue:
|
|
88
|
+
receivedValue: value.converts_to_percent,
|
|
247
89
|
});
|
|
248
90
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
91
|
+
return value.converts_to_percent;
|
|
92
|
+
})()),
|
|
93
|
+
...(value.capitalization_definition ? { capitalization_definition: value.capitalization_definition } : {}),
|
|
94
|
+
...(value.capitalization_definition_rules
|
|
95
|
+
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
96
|
+
: {}),
|
|
97
|
+
};
|
|
98
|
+
return mech;
|
|
99
|
+
}
|
|
100
|
+
case 'OcfConvMechFixedAmount': {
|
|
101
|
+
const mech = {
|
|
102
|
+
type: 'FIXED_AMOUNT_CONVERSION',
|
|
103
|
+
converts_to_quantity: (0, typeConversions_1.normalizeNumericString)(typeof value.converts_to_quantity === 'number'
|
|
104
|
+
? value.converts_to_quantity.toString()
|
|
105
|
+
: (() => {
|
|
106
|
+
if (typeof value.converts_to_quantity !== 'string') {
|
|
107
|
+
throw new errors_1.OcpValidationError('conversion_mechanism.converts_to_quantity', `Must be string or number, got ${typeof value.converts_to_quantity}`, {
|
|
108
|
+
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
109
|
+
expectedType: 'string | number',
|
|
110
|
+
receivedValue: value.converts_to_quantity,
|
|
255
111
|
});
|
|
256
112
|
}
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
113
|
+
return value.converts_to_quantity;
|
|
114
|
+
})()),
|
|
115
|
+
};
|
|
116
|
+
return mech;
|
|
117
|
+
}
|
|
118
|
+
case 'OcfConvMechValuationBased': {
|
|
119
|
+
const mech = {
|
|
120
|
+
type: 'VALUATION_BASED_CONVERSION',
|
|
121
|
+
valuation_type: value.valuation_type,
|
|
122
|
+
...(value.valuation_amount
|
|
123
|
+
? {
|
|
124
|
+
valuation_amount: (() => {
|
|
125
|
+
const monetary = (0, typeConversions_1.damlMonetaryToNativeWithValidation)(value.valuation_amount);
|
|
126
|
+
if (!monetary) {
|
|
127
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.valuation_amount', 'Invalid monetary value for valuation_amount', { code: errors_1.OcpErrorCodes.INVALID_TYPE, receivedValue: value.valuation_amount });
|
|
128
|
+
}
|
|
129
|
+
return monetary;
|
|
130
|
+
})(),
|
|
131
|
+
}
|
|
132
|
+
: {}),
|
|
133
|
+
...(value.capitalization_definition ? { capitalization_definition: value.capitalization_definition } : {}),
|
|
134
|
+
...(value.capitalization_definition_rules
|
|
135
|
+
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
136
|
+
: {}),
|
|
137
|
+
};
|
|
138
|
+
return mech;
|
|
139
|
+
}
|
|
140
|
+
case 'OcfConvMechSharePriceBased': {
|
|
141
|
+
const mech = {
|
|
142
|
+
type: 'SHARE_PRICE_BASED_CONVERSION',
|
|
143
|
+
description: value.description,
|
|
144
|
+
discount: Boolean(value.discount),
|
|
145
|
+
...(value.discount_percentage !== undefined && value.discount_percentage !== null
|
|
146
|
+
? {
|
|
147
|
+
discount_percentage: (0, typeConversions_1.normalizeNumericString)(typeof value.discount_percentage === 'number'
|
|
148
|
+
? value.discount_percentage.toString()
|
|
149
|
+
: typeof value.discount_percentage === 'string'
|
|
150
|
+
? value.discount_percentage
|
|
151
|
+
: (() => {
|
|
152
|
+
throw new errors_1.OcpValidationError('conversion_mechanism.discount_percentage', `Must be string or number, got ${typeof value.discount_percentage}`, {
|
|
153
|
+
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
154
|
+
expectedType: 'string | number',
|
|
155
|
+
receivedValue: value.discount_percentage,
|
|
156
|
+
});
|
|
157
|
+
})()),
|
|
158
|
+
}
|
|
159
|
+
: {}),
|
|
160
|
+
...(value.discount_amount
|
|
161
|
+
? {
|
|
162
|
+
discount_amount: (() => {
|
|
163
|
+
const monetary = (0, typeConversions_1.damlMonetaryToNativeWithValidation)(value.discount_amount);
|
|
164
|
+
if (!monetary) {
|
|
165
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.discount_amount', 'Invalid monetary value for discount_amount', { code: errors_1.OcpErrorCodes.INVALID_TYPE, receivedValue: value.discount_amount });
|
|
166
|
+
}
|
|
167
|
+
return monetary;
|
|
168
|
+
})(),
|
|
169
|
+
}
|
|
170
|
+
: {}),
|
|
171
|
+
};
|
|
172
|
+
return mech;
|
|
173
|
+
}
|
|
174
|
+
case 'OcfConvMechNote': {
|
|
175
|
+
const interest_rates = Array.isArray(value.interest_rates)
|
|
176
|
+
? value.interest_rates.map((ir) => {
|
|
177
|
+
const irObj = ir;
|
|
178
|
+
// Validate interest rate
|
|
179
|
+
if (irObj.rate === undefined || irObj.rate === null) {
|
|
180
|
+
throw new errors_1.OcpValidationError('interest_rate.rate', 'Required field is missing', {
|
|
181
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (typeof irObj.rate !== 'string' && typeof irObj.rate !== 'number') {
|
|
185
|
+
throw new errors_1.OcpValidationError('interest_rate.rate', `Must be string or number, got ${typeof irObj.rate}`, {
|
|
186
|
+
code: errors_1.OcpErrorCodes.INVALID_TYPE,
|
|
187
|
+
expectedType: 'string | number',
|
|
188
|
+
receivedValue: irObj.rate,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Validate accrual_start_date
|
|
192
|
+
if (typeof irObj.accrual_start_date !== 'string' || !irObj.accrual_start_date) {
|
|
193
|
+
throw new errors_1.OcpValidationError('interest_rate.accrual_start_date', 'Required field must be a non-empty string', {
|
|
194
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
195
|
+
expectedType: 'string',
|
|
196
|
+
receivedValue: irObj.accrual_start_date,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
rate: (0, typeConversions_1.normalizeNumericString)(typeof irObj.rate === 'number' ? irObj.rate.toString() : irObj.rate),
|
|
201
|
+
accrual_start_date: irObj.accrual_start_date.split('T')[0],
|
|
202
|
+
...(irObj.accrual_end_date
|
|
203
|
+
? { accrual_end_date: irObj.accrual_end_date.split('T')[0] }
|
|
204
|
+
: {}),
|
|
205
|
+
};
|
|
206
|
+
})
|
|
207
|
+
: null;
|
|
208
|
+
const accrualFromDaml = (v) => {
|
|
209
|
+
const s = (0, typeConversions_1.safeString)(v);
|
|
210
|
+
if (s.endsWith('OcfAccrualDaily') || s === 'OcfAccrualDaily')
|
|
211
|
+
return 'DAILY';
|
|
212
|
+
if (s.endsWith('OcfAccrualMonthly') || s === 'OcfAccrualMonthly')
|
|
213
|
+
return 'MONTHLY';
|
|
214
|
+
if (s.endsWith('OcfAccrualQuarterly') || s === 'OcfAccrualQuarterly')
|
|
215
|
+
return 'QUARTERLY';
|
|
216
|
+
if (s.endsWith('OcfAccrualSemiAnnual') || s === 'OcfAccrualSemiAnnual')
|
|
217
|
+
return 'SEMI_ANNUAL';
|
|
218
|
+
if (s.endsWith('OcfAccrualAnnual') || s === 'OcfAccrualAnnual')
|
|
219
|
+
return 'ANNUAL';
|
|
220
|
+
return undefined;
|
|
221
|
+
};
|
|
222
|
+
const compoundingFromDaml = (v) => {
|
|
223
|
+
const s = (0, typeConversions_1.safeString)(v);
|
|
224
|
+
if (!s)
|
|
278
225
|
return undefined;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return 'SIMPLE';
|
|
286
|
-
if (s === 'OcfCompounding')
|
|
287
|
-
return 'COMPOUNDING';
|
|
288
|
-
throw new errors_1.OcpParseError(`Unknown compounding_type: ${(0, typeConversions_1.safeString)(v)}`, {
|
|
289
|
-
source: 'conversion_mechanism.compounding_type',
|
|
290
|
-
code: errors_1.OcpErrorCodes.UNKNOWN_ENUM_VALUE,
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
const mech = {
|
|
294
|
-
type: 'CONVERTIBLE_NOTE_CONVERSION',
|
|
295
|
-
interest_rates,
|
|
296
|
-
...(value.day_count_convention
|
|
297
|
-
? {
|
|
298
|
-
day_count_convention: (0, typeConversions_1.safeString)(value.day_count_convention).endsWith('Actual365')
|
|
299
|
-
? 'ACTUAL_365'
|
|
300
|
-
: '30_360',
|
|
301
|
-
}
|
|
302
|
-
: {}),
|
|
303
|
-
...(value.interest_payout
|
|
304
|
-
? {
|
|
305
|
-
interest_payout: (0, typeConversions_1.safeString)(value.interest_payout).endsWith('Deferred') ? 'DEFERRED' : 'CASH',
|
|
306
|
-
}
|
|
307
|
-
: {}),
|
|
308
|
-
...(value.interest_accrual_period
|
|
309
|
-
? { interest_accrual_period: accrualFromDaml(value.interest_accrual_period) }
|
|
310
|
-
: {}),
|
|
311
|
-
...(value.compounding_type ? { compounding_type: compoundingFromDaml(value.compounding_type) } : {}),
|
|
312
|
-
...(typeof value.conversion_discount === 'number' || typeof value.conversion_discount === 'string'
|
|
313
|
-
? {
|
|
314
|
-
conversion_discount: (0, typeConversions_1.normalizeNumericString)(typeof value.conversion_discount === 'number'
|
|
315
|
-
? value.conversion_discount.toString()
|
|
316
|
-
: value.conversion_discount),
|
|
317
|
-
}
|
|
318
|
-
: {}),
|
|
319
|
-
...(value.conversion_valuation_cap
|
|
320
|
-
? {
|
|
321
|
-
conversion_valuation_cap: mapMonetary(value.conversion_valuation_cap) ?? {
|
|
322
|
-
amount: '',
|
|
323
|
-
currency: '',
|
|
324
|
-
},
|
|
325
|
-
}
|
|
326
|
-
: {}),
|
|
327
|
-
...(value.capitalization_definition
|
|
328
|
-
? { capitalization_definition: value.capitalization_definition }
|
|
329
|
-
: {}),
|
|
330
|
-
...(value.capitalization_definition_rules
|
|
331
|
-
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
332
|
-
: {}),
|
|
333
|
-
...(value.exit_multiple
|
|
334
|
-
? {
|
|
335
|
-
exit_multiple: {
|
|
336
|
-
numerator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.numerator)),
|
|
337
|
-
denominator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.denominator)),
|
|
338
|
-
},
|
|
339
|
-
}
|
|
340
|
-
: {}),
|
|
341
|
-
...(value.conversion_mfn ? { conversion_mfn: Boolean(value.conversion_mfn) } : {}),
|
|
342
|
-
};
|
|
343
|
-
return mech;
|
|
344
|
-
}
|
|
345
|
-
case 'OcfConvMechCustom': {
|
|
346
|
-
if (!value.custom_conversion_description) {
|
|
347
|
-
throw new errors_1.OcpValidationError('conversion_mechanism.custom_conversion_description', 'Required for CUSTOM_CONVERSION', { code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING });
|
|
348
|
-
}
|
|
349
|
-
const mech = {
|
|
350
|
-
type: 'CUSTOM_CONVERSION',
|
|
351
|
-
custom_conversion_description: value.custom_conversion_description,
|
|
352
|
-
};
|
|
353
|
-
return mech;
|
|
354
|
-
}
|
|
355
|
-
default:
|
|
356
|
-
throw new errors_1.OcpParseError(`Unknown convertible conversion mechanism tag: ${String(tag)}`, {
|
|
357
|
-
source: 'conversion_mechanism.tag',
|
|
226
|
+
if (s === 'OcfSimple')
|
|
227
|
+
return 'SIMPLE';
|
|
228
|
+
if (s === 'OcfCompounding')
|
|
229
|
+
return 'COMPOUNDING';
|
|
230
|
+
throw new errors_1.OcpParseError(`Unknown compounding_type: ${(0, typeConversions_1.safeString)(v)}`, {
|
|
231
|
+
source: 'conversion_mechanism.compounding_type',
|
|
358
232
|
code: errors_1.OcpErrorCodes.UNKNOWN_ENUM_VALUE,
|
|
359
233
|
});
|
|
234
|
+
};
|
|
235
|
+
const mech = {
|
|
236
|
+
type: 'CONVERTIBLE_NOTE_CONVERSION',
|
|
237
|
+
interest_rates,
|
|
238
|
+
...(value.day_count_convention
|
|
239
|
+
? {
|
|
240
|
+
day_count_convention: (0, typeConversions_1.safeString)(value.day_count_convention).endsWith('Actual365')
|
|
241
|
+
? 'ACTUAL_365'
|
|
242
|
+
: '30_360',
|
|
243
|
+
}
|
|
244
|
+
: {}),
|
|
245
|
+
...(value.interest_payout
|
|
246
|
+
? {
|
|
247
|
+
interest_payout: (0, typeConversions_1.safeString)(value.interest_payout).endsWith('Deferred') ? 'DEFERRED' : 'CASH',
|
|
248
|
+
}
|
|
249
|
+
: {}),
|
|
250
|
+
...(value.interest_accrual_period
|
|
251
|
+
? { interest_accrual_period: accrualFromDaml(value.interest_accrual_period) }
|
|
252
|
+
: {}),
|
|
253
|
+
...(value.compounding_type ? { compounding_type: compoundingFromDaml(value.compounding_type) } : {}),
|
|
254
|
+
...(typeof value.conversion_discount === 'number' || typeof value.conversion_discount === 'string'
|
|
255
|
+
? {
|
|
256
|
+
conversion_discount: (0, typeConversions_1.normalizeNumericString)(typeof value.conversion_discount === 'number'
|
|
257
|
+
? value.conversion_discount.toString()
|
|
258
|
+
: value.conversion_discount),
|
|
259
|
+
}
|
|
260
|
+
: {}),
|
|
261
|
+
...(value.conversion_valuation_cap
|
|
262
|
+
? {
|
|
263
|
+
conversion_valuation_cap: (() => {
|
|
264
|
+
const monetary = (0, typeConversions_1.damlMonetaryToNativeWithValidation)(value.conversion_valuation_cap);
|
|
265
|
+
if (!monetary) {
|
|
266
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.conversion_valuation_cap', 'Invalid monetary value for conversion_valuation_cap', { code: errors_1.OcpErrorCodes.INVALID_TYPE, receivedValue: value.conversion_valuation_cap });
|
|
267
|
+
}
|
|
268
|
+
return monetary;
|
|
269
|
+
})(),
|
|
270
|
+
}
|
|
271
|
+
: {}),
|
|
272
|
+
...(value.capitalization_definition ? { capitalization_definition: value.capitalization_definition } : {}),
|
|
273
|
+
...(value.capitalization_definition_rules
|
|
274
|
+
? { capitalization_definition_rules: value.capitalization_definition_rules }
|
|
275
|
+
: {}),
|
|
276
|
+
...(value.exit_multiple
|
|
277
|
+
? {
|
|
278
|
+
exit_multiple: {
|
|
279
|
+
numerator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.numerator)),
|
|
280
|
+
denominator: (0, typeConversions_1.normalizeNumericString)(String(value.exit_multiple.denominator)),
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
: {}),
|
|
284
|
+
...(value.conversion_mfn ? { conversion_mfn: Boolean(value.conversion_mfn) } : {}),
|
|
285
|
+
};
|
|
286
|
+
return mech;
|
|
360
287
|
}
|
|
288
|
+
case 'OcfConvMechCustom': {
|
|
289
|
+
if (!value.custom_conversion_description) {
|
|
290
|
+
throw new errors_1.OcpValidationError('conversion_mechanism.custom_conversion_description', 'Required for CUSTOM_CONVERSION', { code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING });
|
|
291
|
+
}
|
|
292
|
+
const mech = {
|
|
293
|
+
type: 'CUSTOM_CONVERSION',
|
|
294
|
+
custom_conversion_description: value.custom_conversion_description,
|
|
295
|
+
};
|
|
296
|
+
return mech;
|
|
297
|
+
}
|
|
298
|
+
default:
|
|
299
|
+
throw new errors_1.OcpParseError(`Unknown convertible conversion mechanism tag: ${String(tag)}`, {
|
|
300
|
+
source: 'conversion_mechanism.tag',
|
|
301
|
+
code: errors_1.OcpErrorCodes.UNKNOWN_ENUM_VALUE,
|
|
302
|
+
});
|
|
361
303
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
304
|
+
}
|
|
305
|
+
throw new errors_1.OcpParseError('Unknown conversion_mechanism shape', {
|
|
306
|
+
source: 'conversionRight.conversion_mechanism',
|
|
307
|
+
code: errors_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
return ts.map((raw, idx) => {
|
|
311
|
+
const r = (raw ?? {});
|
|
312
|
+
const tag = typeof r.type_ === 'string' ? r.type_ : typeof r.tag === 'string' ? r.tag : typeof raw === 'string' ? raw : '';
|
|
313
|
+
const type = (0, typeConversions_1.mapDamlTriggerTypeToOcf)(String(tag));
|
|
314
|
+
const trigger_id = typeof r.trigger_id === 'string' && r.trigger_id.length ? r.trigger_id : `${issuanceId}-trigger-${idx + 1}`;
|
|
315
|
+
const nickname = typeof r.nickname === 'string' && r.nickname.length ? r.nickname : undefined;
|
|
316
|
+
const trigger_description = typeof r.trigger_description === 'string' && r.trigger_description.length ? r.trigger_description : undefined;
|
|
317
|
+
const trigger_date = typeof r.trigger_date === 'string' && r.trigger_date.length ? r.trigger_date.split('T')[0] : undefined;
|
|
318
|
+
const trigger_condition = typeof r.trigger_condition === 'string' && r.trigger_condition.length ? r.trigger_condition : undefined;
|
|
319
|
+
// Parse conversion_right if present and convertible variant is used
|
|
320
|
+
let conversion_right;
|
|
321
|
+
if (r.conversion_right && typeof r.conversion_right === 'object' && 'OcfRightConvertible' in r.conversion_right) {
|
|
322
|
+
const right = r.conversion_right.OcfRightConvertible;
|
|
323
|
+
conversion_right = {
|
|
324
|
+
type: 'CONVERTIBLE_CONVERSION_RIGHT',
|
|
325
|
+
conversion_mechanism: mapMechanism(right.conversion_mechanism),
|
|
326
|
+
...(typeof right.converts_to_future_round === 'boolean'
|
|
327
|
+
? { converts_to_future_round: right.converts_to_future_round }
|
|
328
|
+
: {}),
|
|
329
|
+
...(typeof right.converts_to_stock_class_id === 'string' && right.converts_to_stock_class_id.length
|
|
330
|
+
? { converts_to_stock_class_id: right.converts_to_stock_class_id }
|
|
331
|
+
: {}),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
else if (r.conversion_right &&
|
|
335
|
+
typeof r.conversion_right === 'object' &&
|
|
336
|
+
'conversion_mechanism' in r.conversion_right) {
|
|
337
|
+
// Handle direct convertible right shape (no OcfRightConvertible wrapper)
|
|
338
|
+
const right = r.conversion_right;
|
|
339
|
+
conversion_right = {
|
|
340
|
+
type: 'CONVERTIBLE_CONVERSION_RIGHT',
|
|
341
|
+
conversion_mechanism: mapMechanism(right.conversion_mechanism),
|
|
342
|
+
...(typeof right.converts_to_future_round === 'boolean'
|
|
343
|
+
? { converts_to_future_round: right.converts_to_future_round }
|
|
344
|
+
: {}),
|
|
345
|
+
...(typeof right.converts_to_stock_class_id === 'string' && right.converts_to_stock_class_id.length
|
|
346
|
+
? { converts_to_stock_class_id: right.converts_to_stock_class_id }
|
|
347
|
+
: {}),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
if (!conversion_right) {
|
|
351
|
+
throw new errors_1.OcpValidationError('conversionTrigger.conversion_right', 'Required field is missing', {
|
|
352
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
365
353
|
});
|
|
354
|
+
}
|
|
355
|
+
const trigger = {
|
|
356
|
+
type,
|
|
357
|
+
trigger_id,
|
|
358
|
+
conversion_right,
|
|
359
|
+
...(nickname ? { nickname } : {}),
|
|
360
|
+
...(trigger_description ? { trigger_description } : {}),
|
|
361
|
+
...(trigger_date ? { trigger_date } : {}),
|
|
362
|
+
...(trigger_condition ? { trigger_condition } : {}),
|
|
366
363
|
};
|
|
367
|
-
return
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
let conversion_right;
|
|
378
|
-
if (r.conversion_right && typeof r.conversion_right === 'object' && 'OcfRightConvertible' in r.conversion_right) {
|
|
379
|
-
const right = r.conversion_right.OcfRightConvertible;
|
|
380
|
-
conversion_right = {
|
|
381
|
-
type: 'CONVERTIBLE_CONVERSION_RIGHT',
|
|
382
|
-
conversion_mechanism: mapMechanism(right.conversion_mechanism),
|
|
383
|
-
...(typeof right.converts_to_future_round === 'boolean'
|
|
384
|
-
? { converts_to_future_round: right.converts_to_future_round }
|
|
385
|
-
: {}),
|
|
386
|
-
...(typeof right.converts_to_stock_class_id === 'string' && right.converts_to_stock_class_id.length
|
|
387
|
-
? { converts_to_stock_class_id: right.converts_to_stock_class_id }
|
|
388
|
-
: {}),
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
else if (r.conversion_right &&
|
|
392
|
-
typeof r.conversion_right === 'object' &&
|
|
393
|
-
'conversion_mechanism' in r.conversion_right) {
|
|
394
|
-
// Handle direct convertible right shape (no OcfRightConvertible wrapper)
|
|
395
|
-
const right = r.conversion_right;
|
|
396
|
-
conversion_right = {
|
|
397
|
-
type: 'CONVERTIBLE_CONVERSION_RIGHT',
|
|
398
|
-
conversion_mechanism: mapMechanism(right.conversion_mechanism),
|
|
399
|
-
...(typeof right.converts_to_future_round === 'boolean'
|
|
400
|
-
? { converts_to_future_round: right.converts_to_future_round }
|
|
401
|
-
: {}),
|
|
402
|
-
...(typeof right.converts_to_stock_class_id === 'string' && right.converts_to_stock_class_id.length
|
|
403
|
-
? { converts_to_stock_class_id: right.converts_to_stock_class_id }
|
|
404
|
-
: {}),
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
if (!conversion_right) {
|
|
408
|
-
throw new errors_1.OcpValidationError('conversionTrigger.conversion_right', 'Required field is missing', {
|
|
409
|
-
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
const trigger = {
|
|
413
|
-
type,
|
|
414
|
-
trigger_id,
|
|
415
|
-
conversion_right,
|
|
416
|
-
...(nickname ? { nickname } : {}),
|
|
417
|
-
...(trigger_description ? { trigger_description } : {}),
|
|
418
|
-
...(trigger_date ? { trigger_date } : {}),
|
|
419
|
-
...(trigger_condition ? { trigger_condition } : {}),
|
|
420
|
-
};
|
|
421
|
-
return trigger;
|
|
364
|
+
return trigger;
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
/** Convert DAML ConvertibleIssuance data to native OCF format */
|
|
368
|
+
function damlConvertibleIssuanceDataToNative(d) {
|
|
369
|
+
// Validate required fields
|
|
370
|
+
if (typeof d.id !== 'string' || !d.id) {
|
|
371
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.id', 'Required field is missing or invalid', {
|
|
372
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
373
|
+
receivedValue: d.id,
|
|
422
374
|
});
|
|
423
|
-
}
|
|
375
|
+
}
|
|
376
|
+
if (typeof d.date !== 'string' || !d.date) {
|
|
377
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.date', 'Required field is missing or invalid', {
|
|
378
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
379
|
+
receivedValue: d.date,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if (typeof d.security_id !== 'string' || !d.security_id) {
|
|
383
|
+
throw new errors_1.OcpValidationError('convertibleIssuance.security_id', 'Required field is missing or invalid', {
|
|
384
|
+
code: errors_1.OcpErrorCodes.REQUIRED_FIELD_MISSING,
|
|
385
|
+
receivedValue: d.security_id,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
424
388
|
const investmentAmount = d.investment_amount;
|
|
425
|
-
const comments = d.comments;
|
|
426
389
|
// Validate investment amount
|
|
427
390
|
if (!investmentAmount ||
|
|
428
391
|
(typeof investmentAmount.amount !== 'string' && typeof investmentAmount.amount !== 'number')) {
|
|
@@ -441,8 +404,10 @@ async function getConvertibleIssuanceAsOcf(client, params) {
|
|
|
441
404
|
}
|
|
442
405
|
// Convert to string after validation
|
|
443
406
|
const investmentAmountStr = typeof investmentAmount.amount === 'number' ? investmentAmount.amount.toString() : investmentAmount.amount;
|
|
444
|
-
|
|
445
|
-
|
|
407
|
+
// Build the issuance object - use type assertion because the local helper types
|
|
408
|
+
// (ConversionTrigger, etc.) have compatible structure but different TypeScript definitions
|
|
409
|
+
// than the native types (ConvertibleConversionTrigger, etc.)
|
|
410
|
+
const issuance = {
|
|
446
411
|
id: d.id,
|
|
447
412
|
date: d.date.split('T')[0],
|
|
448
413
|
security_id: d.security_id,
|
|
@@ -462,7 +427,7 @@ async function getConvertibleIssuanceAsOcf(client, params) {
|
|
|
462
427
|
? { consideration_text: d.consideration_text }
|
|
463
428
|
: {}),
|
|
464
429
|
convertible_type: typeMap[d.convertible_type || 'OcfConvertibleNote'],
|
|
465
|
-
conversion_triggers: convertTriggers(d.conversion_triggers,
|
|
430
|
+
conversion_triggers: convertTriggers(d.conversion_triggers, d.id),
|
|
466
431
|
...(typeof d.pro_rata === 'number' || typeof d.pro_rata === 'string'
|
|
467
432
|
? {
|
|
468
433
|
pro_rata: (0, typeConversions_1.normalizeNumericString)(typeof d.pro_rata === 'number' ? d.pro_rata.toString() : d.pro_rata),
|
|
@@ -470,7 +435,33 @@ async function getConvertibleIssuanceAsOcf(client, params) {
|
|
|
470
435
|
: {}),
|
|
471
436
|
seniority: typeof d.seniority === 'number' ? d.seniority : Number(d.seniority),
|
|
472
437
|
security_law_exemptions: d.security_law_exemptions,
|
|
473
|
-
...(comments.length ? { comments } : {}),
|
|
438
|
+
...(Array.isArray(d.comments) && d.comments.length > 0 ? { comments: d.comments } : {}),
|
|
439
|
+
};
|
|
440
|
+
return issuance;
|
|
441
|
+
}
|
|
442
|
+
/** Retrieve a ConvertibleIssuance contract and return it as an OCF JSON object */
|
|
443
|
+
async function getConvertibleIssuanceAsOcf(client, params) {
|
|
444
|
+
const res = await client.getEventsByContractId({ contractId: params.contractId });
|
|
445
|
+
const created = res.created?.createdEvent;
|
|
446
|
+
if (!created?.createArgument) {
|
|
447
|
+
throw new errors_1.OcpContractError('Missing createArgument for ConvertibleIssuance', {
|
|
448
|
+
contractId: params.contractId,
|
|
449
|
+
code: errors_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
const arg = created.createArgument;
|
|
453
|
+
if (typeof arg !== 'object' || !('issuance_data' in arg)) {
|
|
454
|
+
throw new errors_1.OcpParseError('Unexpected createArgument for ConvertibleIssuance', {
|
|
455
|
+
source: 'ConvertibleIssuance.createArgument',
|
|
456
|
+
code: errors_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
const d = arg.issuance_data;
|
|
460
|
+
const native = damlConvertibleIssuanceDataToNative(d);
|
|
461
|
+
// Add object_type to create the full event type
|
|
462
|
+
const event = {
|
|
463
|
+
object_type: 'TX_CONVERTIBLE_ISSUANCE',
|
|
464
|
+
...native,
|
|
474
465
|
};
|
|
475
466
|
return { event, contractId: params.contractId };
|
|
476
467
|
}
|