@ottochain/sdk 1.7.0-beta.2 → 2.1.0

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.
Files changed (113) hide show
  1. package/dist/cjs/apps/contracts/index.js +1 -1
  2. package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +272 -0
  3. package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +284 -0
  4. package/dist/cjs/apps/contracts/state-machines/contract-universal.js +93 -0
  5. package/dist/cjs/apps/contracts/state-machines/index.js +177 -1
  6. package/dist/cjs/apps/corporate/state-machines/corp-board.js +1022 -0
  7. package/dist/cjs/apps/corporate/state-machines/corp-entity.js +671 -0
  8. package/dist/cjs/apps/corporate/state-machines/corp-securities.js +998 -0
  9. package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +1102 -0
  10. package/dist/cjs/apps/corporate/state-machines/index.js +20 -4440
  11. package/dist/cjs/apps/governance/index.js +7 -7
  12. package/dist/cjs/apps/governance/state-machines/dao-multisig.js +467 -0
  13. package/dist/cjs/apps/governance/state-machines/dao-reputation.js +458 -0
  14. package/dist/cjs/apps/governance/state-machines/dao-single.js +199 -0
  15. package/dist/cjs/apps/governance/state-machines/dao-token.js +503 -0
  16. package/dist/cjs/apps/governance/state-machines/governance-simple.js +482 -0
  17. package/dist/cjs/apps/governance/state-machines/governance-universal.js +138 -0
  18. package/dist/cjs/apps/governance/state-machines/index.js +16 -2934
  19. package/dist/cjs/apps/identity/constants.js +20 -20
  20. package/dist/cjs/apps/identity/index.js +13 -21
  21. package/dist/cjs/apps/identity/state-machines/identity-agent.js +256 -0
  22. package/dist/cjs/apps/identity/state-machines/identity-oracle.js +321 -0
  23. package/dist/cjs/apps/identity/state-machines/identity-universal.js +106 -0
  24. package/dist/cjs/apps/identity/state-machines/index.js +15 -784
  25. package/dist/cjs/apps/markets/index.js +1 -1
  26. package/dist/cjs/apps/markets/state-machines/index.js +14 -2298
  27. package/dist/cjs/apps/markets/state-machines/market-auction.js +283 -0
  28. package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +312 -0
  29. package/dist/cjs/apps/markets/state-machines/market-group-buy.js +407 -0
  30. package/dist/cjs/apps/markets/state-machines/market-prediction.js +485 -0
  31. package/dist/cjs/apps/markets/state-machines/market-universal.js +129 -0
  32. package/dist/cjs/apps/oracles/index.js +36 -0
  33. package/dist/cjs/generated/index.js +14 -7
  34. package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +197 -198
  35. package/dist/cjs/schema/fiber-app.js +55 -0
  36. package/dist/cjs/schema/index.js +20 -0
  37. package/dist/esm/apps/contracts/index.js +3 -3
  38. package/dist/esm/apps/contracts/state-machines/contract-agreement.js +269 -0
  39. package/dist/esm/apps/contracts/state-machines/contract-escrow.js +281 -0
  40. package/dist/esm/apps/contracts/state-machines/contract-universal.js +90 -0
  41. package/dist/esm/apps/contracts/state-machines/index.js +177 -1
  42. package/dist/esm/apps/corporate/index.js +3 -3
  43. package/dist/esm/apps/corporate/state-machines/corp-board.js +1019 -0
  44. package/dist/esm/apps/corporate/state-machines/corp-entity.js +668 -0
  45. package/dist/esm/apps/corporate/state-machines/corp-securities.js +995 -0
  46. package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +1099 -0
  47. package/dist/esm/apps/corporate/state-machines/index.js +15 -4439
  48. package/dist/esm/apps/governance/index.js +9 -9
  49. package/dist/esm/apps/governance/state-machines/dao-multisig.js +464 -0
  50. package/dist/esm/apps/governance/state-machines/dao-reputation.js +455 -0
  51. package/dist/esm/apps/governance/state-machines/dao-single.js +196 -0
  52. package/dist/esm/apps/governance/state-machines/dao-token.js +500 -0
  53. package/dist/esm/apps/governance/state-machines/governance-simple.js +479 -0
  54. package/dist/esm/apps/governance/state-machines/governance-universal.js +135 -0
  55. package/dist/esm/apps/governance/state-machines/index.js +9 -2933
  56. package/dist/esm/apps/identity/constants.js +21 -21
  57. package/dist/esm/apps/identity/index.js +13 -22
  58. package/dist/esm/apps/identity/state-machines/identity-agent.js +253 -0
  59. package/dist/esm/apps/identity/state-machines/identity-oracle.js +318 -0
  60. package/dist/esm/apps/identity/state-machines/identity-universal.js +103 -0
  61. package/dist/esm/apps/identity/state-machines/index.js +11 -783
  62. package/dist/esm/apps/index.js +5 -5
  63. package/dist/esm/apps/markets/index.js +3 -3
  64. package/dist/esm/apps/markets/state-machines/index.js +8 -2297
  65. package/dist/esm/apps/markets/state-machines/market-auction.js +280 -0
  66. package/dist/esm/apps/markets/state-machines/market-crowdfund.js +309 -0
  67. package/dist/esm/apps/markets/state-machines/market-group-buy.js +404 -0
  68. package/dist/esm/apps/markets/state-machines/market-prediction.js +482 -0
  69. package/dist/esm/apps/markets/state-machines/market-universal.js +126 -0
  70. package/dist/esm/apps/oracles/index.js +21 -0
  71. package/dist/esm/generated/index.js +8 -3
  72. package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +196 -197
  73. package/dist/esm/schema/fiber-app.js +47 -0
  74. package/dist/esm/schema/index.js +4 -0
  75. package/dist/types/apps/contracts/index.d.ts +151 -2
  76. package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +462 -0
  77. package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +511 -0
  78. package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +147 -0
  79. package/dist/types/apps/contracts/state-machines/index.d.ts +149 -0
  80. package/dist/types/apps/corporate/index.d.ts +5263 -3825
  81. package/dist/types/apps/corporate/state-machines/corp-board.d.ts +1479 -0
  82. package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +970 -0
  83. package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +1381 -0
  84. package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +1631 -0
  85. package/dist/types/apps/corporate/state-machines/index.d.ts +5245 -3802
  86. package/dist/types/apps/governance/index.d.ts +875 -37
  87. package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +644 -0
  88. package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +610 -0
  89. package/dist/types/apps/governance/state-machines/dao-single.d.ts +276 -0
  90. package/dist/types/apps/governance/state-machines/dao-token.d.ts +601 -0
  91. package/dist/types/apps/governance/state-machines/governance-simple.d.ts +652 -0
  92. package/dist/types/apps/governance/state-machines/governance-universal.d.ts +181 -0
  93. package/dist/types/apps/governance/state-machines/index.d.ts +9 -2136
  94. package/dist/types/apps/identity/constants.d.ts +4 -7
  95. package/dist/types/apps/identity/index.d.ts +1082 -592
  96. package/dist/types/apps/identity/state-machines/identity-agent.d.ts +401 -0
  97. package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +550 -0
  98. package/dist/types/apps/identity/state-machines/identity-universal.d.ts +151 -0
  99. package/dist/types/apps/identity/state-machines/index.d.ts +1069 -567
  100. package/dist/types/apps/index.d.ts +5 -5
  101. package/dist/types/apps/markets/index.d.ts +535 -7
  102. package/dist/types/apps/markets/state-machines/index.d.ts +8 -1678
  103. package/dist/types/apps/markets/state-machines/market-auction.d.ts +392 -0
  104. package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +443 -0
  105. package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +539 -0
  106. package/dist/types/apps/markets/state-machines/market-prediction.d.ts +651 -0
  107. package/dist/types/apps/markets/state-machines/market-universal.d.ts +191 -0
  108. package/dist/types/apps/oracles/index.d.ts +18 -0
  109. package/dist/types/generated/index.d.ts +3 -1
  110. package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +43 -64
  111. package/dist/types/schema/fiber-app.d.ts +139 -0
  112. package/dist/types/schema/index.d.ts +4 -0
  113. package/package.json +1 -1
@@ -0,0 +1,671 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.corpEntityDef = void 0;
4
+ const fiber_app_js_1 = require("../../../schema/fiber-app.js");
5
+ /**
6
+ * Master corporate record tracking the lifecycle of a business entity from incorporation through dissolution.
7
+ * Manages legal identity, share structure, and corporate status.
8
+ */
9
+ exports.corpEntityDef = (0, fiber_app_js_1.defineFiberApp)({
10
+ metadata: {
11
+ name: "CorpEntity",
12
+ app: "corporate",
13
+ type: "entity",
14
+ version: "1.0.0",
15
+ description: "Master corporate record tracking the lifecycle of a business entity from incorporation through dissolution. Manages legal identity, share structure, and corporate status.",
16
+ crossReferences: {
17
+ board: {
18
+ machine: "corporate-board",
19
+ description: "Board of directors for this entity",
20
+ foreignKey: "entityId",
21
+ },
22
+ officers: {
23
+ machine: "corporate-officers",
24
+ description: "Executive officers for this entity",
25
+ foreignKey: "entityId",
26
+ },
27
+ bylaws: {
28
+ machine: "corporate-bylaws",
29
+ description: "Governing bylaws for this entity",
30
+ foreignKey: "entityId",
31
+ },
32
+ shareholders: {
33
+ machine: "corporate-shareholders",
34
+ description: "Shareholder meeting instances",
35
+ foreignKey: "entityId",
36
+ },
37
+ securities: {
38
+ machine: "corporate-securities",
39
+ description: "Stock issuance records",
40
+ foreignKey: "entityId",
41
+ },
42
+ compliance: {
43
+ machine: "corporate-compliance",
44
+ description: "Regulatory compliance tracking",
45
+ foreignKey: "entityId",
46
+ },
47
+ },
48
+ },
49
+ createSchema: {
50
+ required: ["entityId", "legalName", "entityType", "jurisdiction"],
51
+ properties: {
52
+ entityId: {
53
+ type: "string",
54
+ description: "Unique identifier for this corporate entity",
55
+ immutable: true,
56
+ },
57
+ legalName: {
58
+ type: "string",
59
+ description: "Full legal name of the corporation",
60
+ },
61
+ tradeName: {
62
+ type: "string",
63
+ nullable: true,
64
+ description: "DBA or trade name if different",
65
+ },
66
+ entityType: {
67
+ type: "string",
68
+ enum: ["C_CORP", "S_CORP", "B_CORP", "LLC", "LP", "LLP"],
69
+ description: "Legal entity type",
70
+ },
71
+ jurisdiction: {
72
+ type: "object",
73
+ properties: {
74
+ state: {
75
+ type: "string",
76
+ description: "State of incorporation (e.g., DE, NV, WY)",
77
+ },
78
+ country: { type: "string", default: "USA" },
79
+ foreignQualifications: {
80
+ type: "array",
81
+ items: { type: "string" },
82
+ description: "States where foreign qualified to do business",
83
+ },
84
+ },
85
+ },
86
+ fiscalYearEnd: {
87
+ type: "string",
88
+ description: "Fiscal year end (MM-DD format)",
89
+ },
90
+ registeredAgent: {
91
+ type: "object",
92
+ properties: {
93
+ name: { type: "string" },
94
+ address: { type: "object" },
95
+ phone: { type: "string" },
96
+ email: { type: "string" },
97
+ effectiveDate: { type: "string", format: "date" },
98
+ },
99
+ },
100
+ principalOffice: {
101
+ type: "object",
102
+ properties: {
103
+ street: { type: "string" },
104
+ city: { type: "string" },
105
+ state: { type: "string" },
106
+ zip: { type: "string" },
107
+ country: { type: "string", default: "USA" },
108
+ },
109
+ },
110
+ shareStructure: {
111
+ type: "object",
112
+ properties: {
113
+ classes: {
114
+ type: "array",
115
+ items: { $ref: "#/definitions/ShareClass" },
116
+ },
117
+ totalAuthorized: {
118
+ type: "integer",
119
+ description: "Sum of all authorized shares",
120
+ },
121
+ totalIssued: { type: "integer" },
122
+ totalOutstanding: { type: "integer" },
123
+ },
124
+ },
125
+ incorporators: {
126
+ type: "array",
127
+ items: { $ref: "#/definitions/Incorporator" },
128
+ },
129
+ ein: {
130
+ type: "string",
131
+ nullable: true,
132
+ description: "Federal EIN",
133
+ },
134
+ stateIds: {
135
+ type: "object",
136
+ additionalProperties: { type: "string" },
137
+ description: "State-specific entity IDs keyed by state code",
138
+ },
139
+ },
140
+ },
141
+ stateSchema: {
142
+ properties: {
143
+ entityId: { type: "string", immutable: true },
144
+ legalName: { type: "string" },
145
+ tradeName: { type: "string", nullable: true },
146
+ entityType: { type: "string" },
147
+ jurisdiction: { type: "object" },
148
+ formationDate: { type: "string", format: "date", computed: true },
149
+ fiscalYearEnd: { type: "string" },
150
+ registeredAgent: { type: "object" },
151
+ principalOffice: { type: "object" },
152
+ shareStructure: { type: "object" },
153
+ incorporators: { type: "array" },
154
+ ein: { type: "string", nullable: true },
155
+ stateIds: { type: "object" },
156
+ status: {
157
+ type: "string",
158
+ enum: ["INCORPORATING", "ACTIVE", "SUSPENDED", "DISSOLVED"],
159
+ computed: true,
160
+ },
161
+ suspensionReason: { type: "string", nullable: true, computed: true },
162
+ suspensionDate: {
163
+ type: "string",
164
+ format: "date",
165
+ nullable: true,
166
+ computed: true,
167
+ },
168
+ dissolutionDate: {
169
+ type: "string",
170
+ format: "date",
171
+ nullable: true,
172
+ computed: true,
173
+ },
174
+ dissolutionReason: { type: "string", nullable: true, computed: true },
175
+ charterAmendments: {
176
+ type: "array",
177
+ items: { $ref: "#/definitions/CharterAmendment" },
178
+ computed: true,
179
+ },
180
+ createdAt: { type: "timestamp", computed: true },
181
+ updatedAt: { type: "timestamp", computed: true },
182
+ },
183
+ },
184
+ eventSchemas: {
185
+ incorporate: {
186
+ description: "State approves articles of incorporation, corporation comes into existence",
187
+ required: ["approvalDate", "stateFileNumber"],
188
+ properties: {
189
+ approvalDate: { type: "string", format: "date" },
190
+ stateFileNumber: { type: "string" },
191
+ certificateOfIncorporation: {
192
+ type: "string",
193
+ description: "Document reference",
194
+ },
195
+ },
196
+ },
197
+ amend_charter: {
198
+ description: "Amend the certificate/articles of incorporation (requires shareholder approval for most amendments)",
199
+ required: [
200
+ "amendmentId",
201
+ "description",
202
+ "amendmentType",
203
+ "resolutionRef",
204
+ "effectiveDate",
205
+ "filedDate",
206
+ ],
207
+ properties: {
208
+ amendmentId: { type: "string" },
209
+ description: { type: "string" },
210
+ amendmentType: {
211
+ type: "string",
212
+ enum: [
213
+ "NAME_CHANGE",
214
+ "SHARE_AUTHORIZATION",
215
+ "PURPOSE_CHANGE",
216
+ "OTHER",
217
+ ],
218
+ },
219
+ resolutionRef: {
220
+ type: "string",
221
+ description: "Reference to board/shareholder resolution",
222
+ },
223
+ effectiveDate: { type: "string", format: "date" },
224
+ filedDate: { type: "string", format: "date" },
225
+ newShareAuthorization: {
226
+ type: "object",
227
+ nullable: true,
228
+ description: "If increasing/changing authorized shares",
229
+ },
230
+ newLegalName: { type: "string", nullable: true },
231
+ },
232
+ },
233
+ update_share_class: {
234
+ description: "Update authorized shares for an existing class or add new class (requires charter amendment)",
235
+ required: [
236
+ "classId",
237
+ "className",
238
+ "authorized",
239
+ "parValue",
240
+ "votingRights",
241
+ "charterAmendmentRef",
242
+ ],
243
+ properties: {
244
+ classId: { type: "string" },
245
+ className: { type: "string" },
246
+ authorized: { type: "integer" },
247
+ parValue: { type: "number" },
248
+ votingRights: { type: "boolean" },
249
+ votesPerShare: { type: "number", default: 1 },
250
+ liquidationPreference: { type: "number", nullable: true },
251
+ dividendRate: { type: "number", nullable: true },
252
+ convertible: { type: "boolean", default: false },
253
+ charterAmendmentRef: { type: "string" },
254
+ },
255
+ },
256
+ update_registered_agent: {
257
+ description: "Change the registered agent on file with the state",
258
+ required: ["name", "address", "effectiveDate"],
259
+ properties: {
260
+ name: { type: "string" },
261
+ address: { type: "object" },
262
+ phone: { type: "string" },
263
+ email: { type: "string" },
264
+ effectiveDate: { type: "string", format: "date" },
265
+ filingConfirmation: {
266
+ type: "string",
267
+ description: "State filing confirmation number",
268
+ },
269
+ },
270
+ },
271
+ suspend: {
272
+ description: "State suspends corporate powers (typically for tax/filing noncompliance)",
273
+ required: ["reason", "suspensionDate"],
274
+ properties: {
275
+ reason: {
276
+ type: "string",
277
+ enum: [
278
+ "FRANCHISE_TAX_DELINQUENT",
279
+ "ANNUAL_REPORT_MISSING",
280
+ "REGISTERED_AGENT_LAPSE",
281
+ "ADMINISTRATIVE",
282
+ "OTHER",
283
+ ],
284
+ },
285
+ suspensionDate: { type: "string", format: "date" },
286
+ stateNotice: {
287
+ type: "string",
288
+ description: "Reference to state notice",
289
+ },
290
+ cureDeadline: { type: "string", format: "date", nullable: true },
291
+ },
292
+ },
293
+ reinstate: {
294
+ description: "Cure deficiencies and reinstate corporate powers",
295
+ required: [
296
+ "reinstatementDate",
297
+ "curativeActions",
298
+ "stateConfirmation",
299
+ ],
300
+ properties: {
301
+ reinstatementDate: { type: "string", format: "date" },
302
+ curativeActions: {
303
+ type: "array",
304
+ items: { type: "string" },
305
+ description: "List of actions taken to cure",
306
+ },
307
+ stateConfirmation: { type: "string" },
308
+ penaltiesPaid: { type: "number", nullable: true },
309
+ },
310
+ },
311
+ dissolve_voluntary: {
312
+ description: "Voluntary dissolution approved by board and shareholders",
313
+ required: [
314
+ "dissolutionDate",
315
+ "boardResolutionRef",
316
+ "shareholderResolutionRef",
317
+ ],
318
+ properties: {
319
+ dissolutionDate: { type: "string", format: "date" },
320
+ boardResolutionRef: { type: "string" },
321
+ shareholderResolutionRef: { type: "string" },
322
+ windingUpPlan: {
323
+ type: "string",
324
+ description: "Reference to winding up plan",
325
+ },
326
+ certificateOfDissolution: { type: "string" },
327
+ },
328
+ },
329
+ dissolve_administrative: {
330
+ description: "Administrative dissolution by state after prolonged suspension",
331
+ required: ["dissolutionDate", "stateOrder", "reason"],
332
+ properties: {
333
+ dissolutionDate: { type: "string", format: "date" },
334
+ stateOrder: { type: "string" },
335
+ reason: { type: "string" },
336
+ },
337
+ },
338
+ },
339
+ definitions: {
340
+ ShareClass: {
341
+ type: "object",
342
+ properties: {
343
+ className: {
344
+ type: "string",
345
+ description: "e.g., Common, Series A Preferred",
346
+ },
347
+ classId: { type: "string" },
348
+ authorized: { type: "integer", description: "Total shares authorized" },
349
+ issued: { type: "integer", description: "Shares currently issued" },
350
+ outstanding: { type: "integer", description: "Issued minus treasury" },
351
+ treasury: { type: "integer", description: "Shares held by company" },
352
+ parValue: { type: "number", description: "Par value per share" },
353
+ votingRights: {
354
+ type: "boolean",
355
+ description: "Whether class has voting rights",
356
+ },
357
+ votesPerShare: { type: "number", default: 1 },
358
+ liquidationPreference: {
359
+ type: "number",
360
+ nullable: true,
361
+ description: "Liquidation preference multiple",
362
+ },
363
+ dividendRate: {
364
+ type: "number",
365
+ nullable: true,
366
+ description: "Annual dividend rate %",
367
+ },
368
+ convertible: { type: "boolean", default: false },
369
+ conversionRatio: { type: "number", nullable: true },
370
+ antidilution: {
371
+ type: "string",
372
+ enum: [
373
+ "NONE",
374
+ "BROAD_BASED",
375
+ "NARROW_BASED",
376
+ "FULL_RATCHET",
377
+ ],
378
+ nullable: true,
379
+ },
380
+ },
381
+ },
382
+ Incorporator: {
383
+ type: "object",
384
+ properties: {
385
+ name: { type: "string" },
386
+ address: { type: "object" },
387
+ signatureDate: { type: "string", format: "date" },
388
+ },
389
+ },
390
+ CharterAmendment: {
391
+ type: "object",
392
+ properties: {
393
+ amendmentId: { type: "string" },
394
+ description: { type: "string" },
395
+ effectiveDate: { type: "string", format: "date" },
396
+ resolutionRef: {
397
+ type: "string",
398
+ description: "Reference to approving resolution",
399
+ },
400
+ filedDate: { type: "string", format: "date" },
401
+ },
402
+ },
403
+ },
404
+ states: {
405
+ INCORPORATING: {
406
+ id: "INCORPORATING",
407
+ isFinal: false,
408
+ description: "Initial state during formation process. Articles filed but not yet approved by state.",
409
+ },
410
+ ACTIVE: {
411
+ id: "ACTIVE",
412
+ isFinal: false,
413
+ description: "Corporation is in good standing and authorized to conduct business.",
414
+ },
415
+ SUSPENDED: {
416
+ id: "SUSPENDED",
417
+ isFinal: false,
418
+ description: "Corporate powers suspended due to compliance failure (tax, filings, etc). Can be reinstated.",
419
+ },
420
+ DISSOLVED: {
421
+ id: "DISSOLVED",
422
+ isFinal: true,
423
+ description: "Corporation has been legally dissolved. Terminal state.",
424
+ },
425
+ },
426
+ initialState: "INCORPORATING",
427
+ transitions: [
428
+ // INCORPORATING -> ACTIVE
429
+ {
430
+ from: "INCORPORATING",
431
+ to: "ACTIVE",
432
+ eventName: "incorporate",
433
+ guard: {
434
+ and: [
435
+ { "!=": [{ var: "state.legalName" }, null] },
436
+ { "!=": [{ var: "state.jurisdiction.state" }, null] },
437
+ { "!=": [{ var: "state.registeredAgent" }, null] },
438
+ { ">": [{ var: "state.incorporators.length" }, 0] },
439
+ { ">": [{ var: "state.shareStructure.classes.length" }, 0] },
440
+ { ">": [{ var: "state.shareStructure.totalAuthorized" }, 0] },
441
+ ],
442
+ },
443
+ effect: {
444
+ merge: [
445
+ { var: "state" },
446
+ {
447
+ status: "ACTIVE",
448
+ formationDate: { var: "event.approvalDate" },
449
+ updatedAt: { var: "$timestamp" },
450
+ },
451
+ ],
452
+ },
453
+ emits: ["CORPORATION_FORMED"],
454
+ },
455
+ // ACTIVE -> ACTIVE (amend_charter)
456
+ {
457
+ from: "ACTIVE",
458
+ to: "ACTIVE",
459
+ eventName: "amend_charter",
460
+ guard: { "!=": [{ var: "event.resolutionRef" }, null] },
461
+ dependencies: [
462
+ {
463
+ machine: "corporate-resolution",
464
+ instanceRef: { var: "event.resolutionRef" },
465
+ requiredState: "EXECUTED",
466
+ },
467
+ ],
468
+ effect: {
469
+ merge: [
470
+ { var: "state" },
471
+ {
472
+ charterAmendments: {
473
+ cat: [
474
+ { var: "state.charterAmendments" },
475
+ [
476
+ {
477
+ amendmentId: { var: "event.amendmentId" },
478
+ description: { var: "event.description" },
479
+ effectiveDate: { var: "event.effectiveDate" },
480
+ resolutionRef: { var: "event.resolutionRef" },
481
+ filedDate: { var: "event.filedDate" },
482
+ },
483
+ ],
484
+ ],
485
+ },
486
+ legalName: {
487
+ if: [
488
+ { "!=": [{ var: "event.newLegalName" }, null] },
489
+ { var: "event.newLegalName" },
490
+ { var: "state.legalName" },
491
+ ],
492
+ },
493
+ updatedAt: { var: "$timestamp" },
494
+ },
495
+ ],
496
+ },
497
+ emits: ["CHARTER_AMENDED"],
498
+ },
499
+ // ACTIVE -> ACTIVE (update_share_class)
500
+ {
501
+ from: "ACTIVE",
502
+ to: "ACTIVE",
503
+ eventName: "update_share_class",
504
+ guard: {
505
+ some: [
506
+ { var: "state.charterAmendments" },
507
+ {
508
+ "==": [
509
+ { var: ".amendmentId" },
510
+ { var: "event.charterAmendmentRef" },
511
+ ],
512
+ },
513
+ ],
514
+ },
515
+ effect: {
516
+ merge: [
517
+ { var: "state" },
518
+ {
519
+ shareStructure: {
520
+ merge: [
521
+ { var: "state.shareStructure" },
522
+ {
523
+ classes: {
524
+ map: [
525
+ { var: "state.shareStructure.classes" },
526
+ {
527
+ if: [
528
+ {
529
+ "==": [
530
+ { var: ".classId" },
531
+ { var: "event.classId" },
532
+ ],
533
+ },
534
+ {
535
+ classId: { var: "event.classId" },
536
+ className: { var: "event.className" },
537
+ authorized: { var: "event.authorized" },
538
+ issued: 0,
539
+ outstanding: 0,
540
+ treasury: 0,
541
+ parValue: { var: "event.parValue" },
542
+ votingRights: { var: "event.votingRights" },
543
+ votesPerShare: { var: "event.votesPerShare" },
544
+ liquidationPreference: {
545
+ var: "event.liquidationPreference",
546
+ },
547
+ dividendRate: { var: "event.dividendRate" },
548
+ convertible: { var: "event.convertible" },
549
+ },
550
+ { var: "" },
551
+ ],
552
+ },
553
+ ],
554
+ },
555
+ },
556
+ ],
557
+ },
558
+ },
559
+ ],
560
+ },
561
+ },
562
+ // ACTIVE -> ACTIVE (update_registered_agent)
563
+ {
564
+ from: "ACTIVE",
565
+ to: "ACTIVE",
566
+ eventName: "update_registered_agent",
567
+ guard: { "==": [1, 1] },
568
+ effect: {
569
+ merge: [
570
+ { var: "state" },
571
+ {
572
+ registeredAgent: {
573
+ name: { var: "event.name" },
574
+ address: { var: "event.address" },
575
+ phone: { var: "event.phone" },
576
+ email: { var: "event.email" },
577
+ effectiveDate: { var: "event.effectiveDate" },
578
+ },
579
+ },
580
+ ],
581
+ },
582
+ emits: ["REGISTERED_AGENT_CHANGED"],
583
+ },
584
+ // ACTIVE -> SUSPENDED
585
+ {
586
+ from: "ACTIVE",
587
+ to: "SUSPENDED",
588
+ eventName: "suspend",
589
+ guard: { "==": [1, 1] },
590
+ effect: {
591
+ merge: [
592
+ { var: "state" },
593
+ {
594
+ status: "SUSPENDED",
595
+ suspensionReason: { var: "event.reason" },
596
+ suspensionDate: { var: "event.suspensionDate" },
597
+ },
598
+ ],
599
+ },
600
+ emits: ["CORPORATION_SUSPENDED"],
601
+ },
602
+ // SUSPENDED -> ACTIVE
603
+ {
604
+ from: "SUSPENDED",
605
+ to: "ACTIVE",
606
+ eventName: "reinstate",
607
+ guard: { "==": [1, 1] },
608
+ effect: {
609
+ merge: [
610
+ { var: "state" },
611
+ {
612
+ status: "ACTIVE",
613
+ suspensionReason: null,
614
+ suspensionDate: null,
615
+ },
616
+ ],
617
+ },
618
+ emits: ["CORPORATION_REINSTATED"],
619
+ },
620
+ // ACTIVE -> DISSOLVED (voluntary)
621
+ {
622
+ from: "ACTIVE",
623
+ to: "DISSOLVED",
624
+ eventName: "dissolve_voluntary",
625
+ guard: { "==": [1, 1] },
626
+ dependencies: [
627
+ {
628
+ machine: "corporate-resolution",
629
+ instanceRef: { var: "event.boardResolutionRef" },
630
+ requiredState: "EXECUTED",
631
+ },
632
+ {
633
+ machine: "corporate-resolution",
634
+ instanceRef: { var: "event.shareholderResolutionRef" },
635
+ requiredState: "EXECUTED",
636
+ },
637
+ ],
638
+ effect: {
639
+ merge: [
640
+ { var: "state" },
641
+ {
642
+ status: "DISSOLVED",
643
+ dissolutionDate: { var: "event.dissolutionDate" },
644
+ dissolutionReason: "VOLUNTARY",
645
+ },
646
+ ],
647
+ },
648
+ emits: ["CORPORATION_DISSOLVED"],
649
+ },
650
+ // SUSPENDED -> DISSOLVED (administrative)
651
+ {
652
+ from: "SUSPENDED",
653
+ to: "DISSOLVED",
654
+ eventName: "dissolve_administrative",
655
+ guard: { "==": [1, 1] },
656
+ effect: {
657
+ merge: [
658
+ { var: "state" },
659
+ {
660
+ status: "DISSOLVED",
661
+ dissolutionDate: { var: "event.dissolutionDate" },
662
+ dissolutionReason: {
663
+ cat: ["ADMINISTRATIVE: ", { var: "event.reason" }],
664
+ },
665
+ },
666
+ ],
667
+ },
668
+ emits: ["CORPORATION_DISSOLVED"],
669
+ },
670
+ ],
671
+ });