@ottochain/sdk 2.2.4 → 2.3.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 (85) hide show
  1. package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +54 -6
  2. package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +72 -8
  3. package/dist/cjs/apps/contracts/state-machines/contract-universal.js +36 -4
  4. package/dist/cjs/apps/governance/state-machines/dao-multisig.js +27 -3
  5. package/dist/cjs/apps/governance/state-machines/dao-reputation.js +27 -3
  6. package/dist/cjs/apps/governance/state-machines/dao-single.js +27 -3
  7. package/dist/cjs/apps/governance/state-machines/dao-token.js +36 -4
  8. package/dist/cjs/apps/governance/state-machines/governance-simple.js +36 -4
  9. package/dist/cjs/apps/governance/state-machines/governance-universal.js +27 -3
  10. package/dist/cjs/apps/identity/state-machines/identity-agent.js +54 -6
  11. package/dist/cjs/apps/identity/state-machines/identity-oracle.js +45 -5
  12. package/dist/cjs/apps/identity/state-machines/identity-universal.js +27 -3
  13. package/dist/cjs/apps/markets/state-machines/market-auction.js +30 -6
  14. package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +25 -5
  15. package/dist/cjs/apps/markets/state-machines/market-group-buy.js +29 -5
  16. package/dist/cjs/apps/markets/state-machines/market-prediction.js +40 -8
  17. package/dist/cjs/apps/markets/state-machines/market-universal.js +45 -5
  18. package/dist/cjs/generated/ottochain/v1/common.js +1722 -1
  19. package/dist/cjs/generated/ottochain/v1/fiber.js +352 -2
  20. package/dist/cjs/generated/ottochain/v1/messages.js +775 -3
  21. package/dist/cjs/generated/ottochain/v1/records.js +350 -3
  22. package/dist/cjs/index.js +5 -1
  23. package/dist/cjs/ottochain/genesis-manifest.js +193 -0
  24. package/dist/cjs/ottochain/index.js +5 -1
  25. package/dist/cjs/ottochain/normalize.js +26 -48
  26. package/dist/cjs/ottochain/types.js +4 -0
  27. package/dist/esm/apps/contracts/state-machines/contract-agreement.js +54 -6
  28. package/dist/esm/apps/contracts/state-machines/contract-escrow.js +72 -8
  29. package/dist/esm/apps/contracts/state-machines/contract-universal.js +36 -4
  30. package/dist/esm/apps/governance/state-machines/dao-multisig.js +27 -3
  31. package/dist/esm/apps/governance/state-machines/dao-reputation.js +27 -3
  32. package/dist/esm/apps/governance/state-machines/dao-single.js +27 -3
  33. package/dist/esm/apps/governance/state-machines/dao-token.js +36 -4
  34. package/dist/esm/apps/governance/state-machines/governance-simple.js +36 -4
  35. package/dist/esm/apps/governance/state-machines/governance-universal.js +27 -3
  36. package/dist/esm/apps/identity/state-machines/identity-agent.js +54 -6
  37. package/dist/esm/apps/identity/state-machines/identity-oracle.js +45 -5
  38. package/dist/esm/apps/identity/state-machines/identity-universal.js +27 -3
  39. package/dist/esm/apps/markets/state-machines/market-auction.js +30 -6
  40. package/dist/esm/apps/markets/state-machines/market-crowdfund.js +25 -5
  41. package/dist/esm/apps/markets/state-machines/market-group-buy.js +29 -5
  42. package/dist/esm/apps/markets/state-machines/market-prediction.js +40 -8
  43. package/dist/esm/apps/markets/state-machines/market-universal.js +45 -5
  44. package/dist/esm/generated/ottochain/v1/common.js +1718 -0
  45. package/dist/esm/generated/ottochain/v1/fiber.js +351 -1
  46. package/dist/esm/generated/ottochain/v1/messages.js +774 -2
  47. package/dist/esm/generated/ottochain/v1/records.js +349 -2
  48. package/dist/esm/index.js +2 -0
  49. package/dist/esm/ottochain/genesis-manifest.js +189 -0
  50. package/dist/esm/ottochain/index.js +2 -0
  51. package/dist/esm/ottochain/normalize.js +26 -48
  52. package/dist/esm/ottochain/types.js +4 -0
  53. package/dist/types/apps/contracts/index.d.ts +90 -18
  54. package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +30 -6
  55. package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +40 -8
  56. package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +20 -4
  57. package/dist/types/apps/governance/index.d.ts +114 -33
  58. package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +15 -3
  59. package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +15 -3
  60. package/dist/types/apps/governance/state-machines/dao-single.d.ts +15 -3
  61. package/dist/types/apps/governance/state-machines/dao-token.d.ts +20 -4
  62. package/dist/types/apps/governance/state-machines/governance-simple.d.ts +20 -4
  63. package/dist/types/apps/governance/state-machines/governance-universal.d.ts +15 -3
  64. package/dist/types/apps/identity/index.d.ts +71 -6
  65. package/dist/types/apps/identity/state-machines/identity-agent.d.ts +30 -0
  66. package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +25 -0
  67. package/dist/types/apps/identity/state-machines/identity-universal.d.ts +15 -0
  68. package/dist/types/apps/markets/index.d.ts +80 -5
  69. package/dist/types/apps/markets/state-machines/market-auction.d.ts +12 -0
  70. package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +10 -0
  71. package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +14 -0
  72. package/dist/types/apps/markets/state-machines/market-prediction.d.ts +16 -0
  73. package/dist/types/apps/markets/state-machines/market-universal.d.ts +25 -5
  74. package/dist/types/generated/ottochain/v1/common.d.ts +228 -0
  75. package/dist/types/generated/ottochain/v1/fiber.d.ts +32 -1
  76. package/dist/types/generated/ottochain/v1/messages.d.ts +84 -0
  77. package/dist/types/generated/ottochain/v1/records.d.ts +34 -0
  78. package/dist/types/index.d.ts +3 -1
  79. package/dist/types/ottochain/genesis-manifest.d.ts +130 -0
  80. package/dist/types/ottochain/index.d.ts +3 -1
  81. package/dist/types/ottochain/normalize.d.ts +17 -25
  82. package/dist/types/ottochain/types.d.ts +288 -2
  83. package/dist/types/schema/fiber-app.d.ts +40 -1
  84. package/dist/types/validation.d.ts +17 -17
  85. package/package.json +30 -27
@@ -16,5 +16,7 @@ export { createTransitionPayload, createArchivePayload, createInvokeScriptPayloa
16
16
  // Data utilities
17
17
  export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage, } from './normalize.js';
18
18
  export { dropNulls } from './drop-nulls.js';
19
+ // Genesis manifest exporter (std-app pre-registration content)
20
+ export { buildGenesisManifest, GENESIS_MANIFEST_VERSION } from './genesis-manifest.js';
19
21
  // Note: Governance and Corporate types are now in src/apps/
20
22
  // Import from '@ottochain/sdk/apps' instead
@@ -2,39 +2,30 @@
2
2
  * Normalize OttoChain Messages for Signing
3
3
  *
4
4
  * Converts OttoChain message objects to the wire format expected by the
5
- * Scala metagraph. Metakit's JsonBinaryCodec (used by OttoChain for data
6
- * transaction signing) canonicalizes JSON with dropNullValues = true.
5
+ * Scala metagraph. Specifically, ensures all `Option[A]=None` fields are
6
+ * present as explicit `null` values, matching what circe's magnolia encoder
7
+ * produces on the Scala side.
7
8
  *
8
- * NOTE: This is Metakit's codec, NOT tessellation's JsonSerializer (which
9
- * uses Brotli compression for snapshots/consensus a different layer).
10
- * Different layers use different byte-sequence encoders.
9
+ * This is necessary because metakit's `JsonBinaryCodec.deriveDataUpdate`
10
+ * (rc.8) canonicalizes the circe-encoded JSON **including null fields**.
11
+ * If the TypeScript client omits optional fields (undefined), the canonical
12
+ * JSON won't match and signature verification will fail.
11
13
  *
12
- * Because Metakit drops null fields during canonicalization, the canonical
13
- * JSON used for signature verification **omits** null fields entirely.
14
- * If the TypeScript client includes explicit nulls (e.g., `"metadata": null`),
15
- * the canonical form won't match and signature verification will fail.
16
- *
17
- * Schema mapping (Scala → TypeScript wire format):
18
- * - `Option[A] = None` → field OMITTED (not null, not undefined)
14
+ * Schema mapping (Scala TypeScript):
15
+ * - `Option[A] = None` `null` (must be explicit, not undefined/absent)
19
16
  * - `Option[A] = Some(v)` → `v`
20
- * - `List.empty` / `Set.empty` → `[]`
17
+ * - `List.empty` → `[]`
21
18
  * - `Map.empty` → `{}`
22
- * - `Boolean = false` → `false` (always include, not a null/Option)
23
19
  */
24
20
  /**
25
- * Normalize a State object for wire format.
26
- * State: id (required), isFinal (default false), metadata (Option = None)
27
- * Omit metadata when null/undefined (dropNullValues).
21
+ * Normalize a State object for wire format
28
22
  */
29
23
  function normalizeState(state) {
30
- const result = {
24
+ return {
31
25
  id: state.id,
32
26
  isFinal: state.isFinal ?? false,
27
+ metadata: state.metadata ?? null,
33
28
  };
34
- if (state.metadata != null) {
35
- result.metadata = state.metadata;
36
- }
37
- return result;
38
29
  }
39
30
  /**
40
31
  * Normalize a Transition object for wire format
@@ -86,54 +77,41 @@ function normalizeDefinition(def) {
86
77
  }
87
78
  const transitions = def.transitions ?? [];
88
79
  // Strip FiberAppMetadata if present — it's TypeScript-only, not part of wire format.
89
- // Omit metadata entirely when null/FiberAppMetadata (dropNullValues = true on Scala side).
90
- const wireMetadata = isFiberAppMetadata(def.metadata) ? undefined : def.metadata;
91
- const result = {
80
+ // The Scala schema has `metadata: Option[Json] = None`, so use null for wire format.
81
+ const wireMetadata = isFiberAppMetadata(def.metadata) ? null : (def.metadata ?? null);
82
+ return {
92
83
  states: normalizedStates,
93
84
  initialState: def.initialState,
94
85
  transitions: transitions.map(normalizeTransition),
86
+ metadata: wireMetadata,
95
87
  };
96
- if (wireMetadata != null) {
97
- result.metadata = wireMetadata;
98
- }
99
- return result;
100
88
  }
101
89
  /**
102
90
  * Normalize a CreateStateMachine message for wire format
103
91
  *
104
- * Metakit's JsonBinaryCodec uses dropNullValues = true for canonicalization.
105
- * Optional fields at their defaults must be OMITTED (not set to null)
106
- * to match the canonical JSON used for signature verification.
107
- *
108
- * - definition.metadataOMITTED when absent/FiberAppMetadata
109
- * - definition.states[*].metadata → OMITTED when absent
110
- * - definition.transitions[*].dependencies → [] (Set.empty default, always included)
111
- * - parentFiberId → OMITTED when absent (Option[UUID] = None)
112
- * - participants → OMITTED when absent (Option[Set[Address]] = None)
92
+ * Ensures all Option/default fields are explicit in wire format:
93
+ * - definition.metadata null when absent
94
+ * - definition.states[*].metadata null when absent
95
+ * - definition.transitions[*].dependencies → [] when absent
96
+ * - parentFiberIdnull when absent
113
97
  *
114
98
  * @example
115
99
  * ```typescript
116
100
  * const message = normalizeCreateStateMachine({
117
101
  * fiberId: '...',
118
- * definition: { states: { INIT: { id: 'INIT', isFinal: false } }, ... },
102
+ * definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
119
103
  * initialData: {}
120
104
  * });
121
- * // Optional fields are absent (not null): no parentFiberId, no metadata, etc.
105
+ * // message now has parentFiberId: null, definition.metadata: null, etc.
122
106
  * ```
123
107
  */
124
108
  export function normalizeCreateStateMachine(msg) {
125
- const result = {
109
+ return {
126
110
  fiberId: msg.fiberId,
127
111
  definition: normalizeDefinition(msg.definition),
128
112
  initialData: msg.initialData ?? {},
113
+ parentFiberId: msg.parentFiberId ?? null,
129
114
  };
130
- if (msg.parentFiberId != null) {
131
- result.parentFiberId = msg.parentFiberId;
132
- }
133
- if (msg.participants != null) {
134
- result.participants = msg.participants;
135
- }
136
- return result;
137
115
  }
138
116
  /**
139
117
  * Normalize a TransitionStateMachine message for wire format
@@ -15,6 +15,10 @@ export const OTTOCHAIN_MESSAGE_TYPES = [
15
15
  'CreateStateMachine',
16
16
  'TransitionStateMachine',
17
17
  'ArchiveStateMachine',
18
+ 'UpgradeFiber',
18
19
  'CreateScript',
19
20
  'InvokeScript',
21
+ 'PublishVersion',
22
+ 'SetVersionStatus',
23
+ 'RegisterAlias',
20
24
  ];
@@ -63,22 +63,38 @@ export declare const CONTRACTS_DEFINITIONS: {
63
63
  PROPOSED: {
64
64
  id: string;
65
65
  isFinal: false;
66
- metadata: null;
66
+ metadata: {
67
+ label: string;
68
+ description: string;
69
+ category: "initial";
70
+ };
67
71
  };
68
72
  ACTIVE: {
69
73
  id: string;
70
74
  isFinal: false;
71
- metadata: null;
75
+ metadata: {
76
+ label: string;
77
+ description: string;
78
+ category: "active";
79
+ };
72
80
  };
73
81
  COMPLETED: {
74
82
  id: string;
75
83
  isFinal: true;
76
- metadata: null;
84
+ metadata: {
85
+ label: string;
86
+ description: string;
87
+ category: "terminal";
88
+ };
77
89
  };
78
90
  CANCELLED: {
79
91
  id: string;
80
92
  isFinal: true;
81
- metadata: null;
93
+ metadata: {
94
+ label: string;
95
+ description: string;
96
+ category: "terminal";
97
+ };
82
98
  };
83
99
  };
84
100
  initialState: "PROPOSED";
@@ -326,32 +342,56 @@ export declare const CONTRACTS_DEFINITIONS: {
326
342
  PROPOSED: {
327
343
  id: string;
328
344
  isFinal: false;
329
- metadata: null;
345
+ metadata: {
346
+ label: string;
347
+ description: string;
348
+ category: "initial";
349
+ };
330
350
  };
331
351
  ACTIVE: {
332
352
  id: string;
333
353
  isFinal: false;
334
- metadata: null;
354
+ metadata: {
355
+ label: string;
356
+ description: string;
357
+ category: "active";
358
+ };
335
359
  };
336
360
  COMPLETED: {
337
361
  id: string;
338
362
  isFinal: true;
339
- metadata: null;
363
+ metadata: {
364
+ label: string;
365
+ description: string;
366
+ category: "terminal";
367
+ };
340
368
  };
341
369
  DISPUTED: {
342
370
  id: string;
343
371
  isFinal: false;
344
- metadata: null;
372
+ metadata: {
373
+ label: string;
374
+ description: string;
375
+ category: "pending";
376
+ };
345
377
  };
346
378
  REJECTED: {
347
379
  id: string;
348
380
  isFinal: true;
349
- metadata: null;
381
+ metadata: {
382
+ label: string;
383
+ description: string;
384
+ category: "terminal";
385
+ };
350
386
  };
351
387
  CANCELLED: {
352
388
  id: string;
353
389
  isFinal: true;
354
- metadata: null;
390
+ metadata: {
391
+ label: string;
392
+ description: string;
393
+ category: "terminal";
394
+ };
355
395
  };
356
396
  };
357
397
  initialState: "PROPOSED";
@@ -812,42 +852,74 @@ export declare const CONTRACTS_DEFINITIONS: {
812
852
  CREATED: {
813
853
  id: string;
814
854
  isFinal: false;
815
- metadata: null;
855
+ metadata: {
856
+ label: string;
857
+ description: string;
858
+ category: "initial";
859
+ };
816
860
  };
817
861
  FUNDED: {
818
862
  id: string;
819
863
  isFinal: false;
820
- metadata: null;
864
+ metadata: {
865
+ label: string;
866
+ description: string;
867
+ category: "active";
868
+ };
821
869
  };
822
870
  ACTIVE: {
823
871
  id: string;
824
872
  isFinal: false;
825
- metadata: null;
873
+ metadata: {
874
+ label: string;
875
+ description: string;
876
+ category: "active";
877
+ };
826
878
  };
827
879
  RELEASING: {
828
880
  id: string;
829
881
  isFinal: false;
830
- metadata: null;
882
+ metadata: {
883
+ label: string;
884
+ description: string;
885
+ category: "pending";
886
+ };
831
887
  };
832
888
  DISPUTED: {
833
889
  id: string;
834
890
  isFinal: false;
835
- metadata: null;
891
+ metadata: {
892
+ label: string;
893
+ description: string;
894
+ category: "pending";
895
+ };
836
896
  };
837
897
  RELEASED: {
838
898
  id: string;
839
899
  isFinal: true;
840
- metadata: null;
900
+ metadata: {
901
+ label: string;
902
+ description: string;
903
+ category: "terminal";
904
+ };
841
905
  };
842
906
  REFUNDED: {
843
907
  id: string;
844
908
  isFinal: true;
845
- metadata: null;
909
+ metadata: {
910
+ label: string;
911
+ description: string;
912
+ category: "terminal";
913
+ };
846
914
  };
847
915
  SPLIT: {
848
916
  id: string;
849
917
  isFinal: true;
850
- metadata: null;
918
+ metadata: {
919
+ label: string;
920
+ description: string;
921
+ category: "terminal";
922
+ };
851
923
  };
852
924
  };
853
925
  initialState: "CREATED";
@@ -159,32 +159,56 @@ export declare const contractAgreementDef: {
159
159
  PROPOSED: {
160
160
  id: string;
161
161
  isFinal: false;
162
- metadata: null;
162
+ metadata: {
163
+ label: string;
164
+ description: string;
165
+ category: "initial";
166
+ };
163
167
  };
164
168
  ACTIVE: {
165
169
  id: string;
166
170
  isFinal: false;
167
- metadata: null;
171
+ metadata: {
172
+ label: string;
173
+ description: string;
174
+ category: "active";
175
+ };
168
176
  };
169
177
  COMPLETED: {
170
178
  id: string;
171
179
  isFinal: true;
172
- metadata: null;
180
+ metadata: {
181
+ label: string;
182
+ description: string;
183
+ category: "terminal";
184
+ };
173
185
  };
174
186
  DISPUTED: {
175
187
  id: string;
176
188
  isFinal: false;
177
- metadata: null;
189
+ metadata: {
190
+ label: string;
191
+ description: string;
192
+ category: "pending";
193
+ };
178
194
  };
179
195
  REJECTED: {
180
196
  id: string;
181
197
  isFinal: true;
182
- metadata: null;
198
+ metadata: {
199
+ label: string;
200
+ description: string;
201
+ category: "terminal";
202
+ };
183
203
  };
184
204
  CANCELLED: {
185
205
  id: string;
186
206
  isFinal: true;
187
- metadata: null;
207
+ metadata: {
208
+ label: string;
209
+ description: string;
210
+ category: "terminal";
211
+ };
188
212
  };
189
213
  };
190
214
  initialState: "PROPOSED";
@@ -186,42 +186,74 @@ export declare const contractEscrowDef: {
186
186
  CREATED: {
187
187
  id: string;
188
188
  isFinal: false;
189
- metadata: null;
189
+ metadata: {
190
+ label: string;
191
+ description: string;
192
+ category: "initial";
193
+ };
190
194
  };
191
195
  FUNDED: {
192
196
  id: string;
193
197
  isFinal: false;
194
- metadata: null;
198
+ metadata: {
199
+ label: string;
200
+ description: string;
201
+ category: "active";
202
+ };
195
203
  };
196
204
  ACTIVE: {
197
205
  id: string;
198
206
  isFinal: false;
199
- metadata: null;
207
+ metadata: {
208
+ label: string;
209
+ description: string;
210
+ category: "active";
211
+ };
200
212
  };
201
213
  RELEASING: {
202
214
  id: string;
203
215
  isFinal: false;
204
- metadata: null;
216
+ metadata: {
217
+ label: string;
218
+ description: string;
219
+ category: "pending";
220
+ };
205
221
  };
206
222
  DISPUTED: {
207
223
  id: string;
208
224
  isFinal: false;
209
- metadata: null;
225
+ metadata: {
226
+ label: string;
227
+ description: string;
228
+ category: "pending";
229
+ };
210
230
  };
211
231
  RELEASED: {
212
232
  id: string;
213
233
  isFinal: true;
214
- metadata: null;
234
+ metadata: {
235
+ label: string;
236
+ description: string;
237
+ category: "terminal";
238
+ };
215
239
  };
216
240
  REFUNDED: {
217
241
  id: string;
218
242
  isFinal: true;
219
- metadata: null;
243
+ metadata: {
244
+ label: string;
245
+ description: string;
246
+ category: "terminal";
247
+ };
220
248
  };
221
249
  SPLIT: {
222
250
  id: string;
223
251
  isFinal: true;
224
- metadata: null;
252
+ metadata: {
253
+ label: string;
254
+ description: string;
255
+ category: "terminal";
256
+ };
225
257
  };
226
258
  };
227
259
  initialState: "CREATED";
@@ -40,22 +40,38 @@ export declare const contractUniversalDef: {
40
40
  PROPOSED: {
41
41
  id: string;
42
42
  isFinal: false;
43
- metadata: null;
43
+ metadata: {
44
+ label: string;
45
+ description: string;
46
+ category: "initial";
47
+ };
44
48
  };
45
49
  ACTIVE: {
46
50
  id: string;
47
51
  isFinal: false;
48
- metadata: null;
52
+ metadata: {
53
+ label: string;
54
+ description: string;
55
+ category: "active";
56
+ };
49
57
  };
50
58
  COMPLETED: {
51
59
  id: string;
52
60
  isFinal: true;
53
- metadata: null;
61
+ metadata: {
62
+ label: string;
63
+ description: string;
64
+ category: "terminal";
65
+ };
54
66
  };
55
67
  CANCELLED: {
56
68
  id: string;
57
69
  isFinal: true;
58
- metadata: null;
70
+ metadata: {
71
+ label: string;
72
+ description: string;
73
+ category: "terminal";
74
+ };
59
75
  };
60
76
  };
61
77
  initialState: "PROPOSED";