@ottochain/sdk 2.2.2 → 2.2.3

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.
@@ -54,8 +54,21 @@ function normalizeTransition(t) {
54
54
  dependencies: t.dependencies ?? [],
55
55
  };
56
56
  }
57
+ /**
58
+ * Check if a value looks like FiberAppMetadata (has 'name' and 'app' fields).
59
+ * These TypeScript-only fields should be stripped before sending to metagraph.
60
+ */
61
+ function isFiberAppMetadata(value) {
62
+ return (typeof value === 'object' &&
63
+ value !== null &&
64
+ 'name' in value &&
65
+ 'app' in value);
66
+ }
57
67
  /**
58
68
  * Normalize a StateMachineDefinition for wire format
69
+ *
70
+ * Strips FiberAppMetadata from the definition — the Scala schema expects
71
+ * `metadata: Option[Json] = None`, not the TypeScript app metadata object.
59
72
  */
60
73
  function normalizeDefinition(def) {
61
74
  const states = def.states;
@@ -66,11 +79,14 @@ function normalizeDefinition(def) {
66
79
  }
67
80
  }
68
81
  const transitions = def.transitions ?? [];
82
+ // Strip FiberAppMetadata if present — it's TypeScript-only, not part of wire format.
83
+ // The Scala schema has `metadata: Option[Json] = None`, so use null for wire format.
84
+ const wireMetadata = isFiberAppMetadata(def.metadata) ? null : (def.metadata ?? null);
69
85
  return {
70
86
  states: normalizedStates,
71
87
  initialState: def.initialState,
72
88
  transitions: transitions.map(normalizeTransition),
73
- metadata: def.metadata ?? null,
89
+ metadata: wireMetadata,
74
90
  };
75
91
  }
76
92
  /**
@@ -51,8 +51,21 @@ function normalizeTransition(t) {
51
51
  dependencies: t.dependencies ?? [],
52
52
  };
53
53
  }
54
+ /**
55
+ * Check if a value looks like FiberAppMetadata (has 'name' and 'app' fields).
56
+ * These TypeScript-only fields should be stripped before sending to metagraph.
57
+ */
58
+ function isFiberAppMetadata(value) {
59
+ return (typeof value === 'object' &&
60
+ value !== null &&
61
+ 'name' in value &&
62
+ 'app' in value);
63
+ }
54
64
  /**
55
65
  * Normalize a StateMachineDefinition for wire format
66
+ *
67
+ * Strips FiberAppMetadata from the definition — the Scala schema expects
68
+ * `metadata: Option[Json] = None`, not the TypeScript app metadata object.
56
69
  */
57
70
  function normalizeDefinition(def) {
58
71
  const states = def.states;
@@ -63,11 +76,14 @@ function normalizeDefinition(def) {
63
76
  }
64
77
  }
65
78
  const transitions = def.transitions ?? [];
79
+ // Strip FiberAppMetadata if present — it's TypeScript-only, not part of wire format.
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);
66
82
  return {
67
83
  states: normalizedStates,
68
84
  initialState: def.initialState,
69
85
  transitions: transitions.map(normalizeTransition),
70
- metadata: def.metadata ?? null,
86
+ metadata: wireMetadata,
71
87
  };
72
88
  }
73
89
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottochain/sdk",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "TypeScript SDK for ottochain metagraph operations - signing, encoding, and network interactions",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",