@ottochain/sdk 1.4.2 → 1.5.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.
|
@@ -32,15 +32,26 @@ function normalizeState(state) {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Normalize a Transition object for wire format
|
|
35
|
+
*
|
|
36
|
+
* Scala Transition schema:
|
|
37
|
+
* from: StateId (required)
|
|
38
|
+
* to: StateId (required)
|
|
39
|
+
* eventName: String (required)
|
|
40
|
+
* guard: JsonLogicExpression (required)
|
|
41
|
+
* effect: JsonLogicExpression (required)
|
|
42
|
+
* dependencies: Set[UUID] = Set.empty
|
|
43
|
+
*
|
|
44
|
+
* `dependencies` serializes as `[]` when empty (default). Both `guard`
|
|
45
|
+
* and `effect` are required non-optional fields.
|
|
35
46
|
*/
|
|
36
47
|
function normalizeTransition(t) {
|
|
37
48
|
return {
|
|
38
49
|
from: t.from,
|
|
39
|
-
eventName: t.eventName,
|
|
40
50
|
to: t.to,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
eventName: t.eventName,
|
|
52
|
+
guard: t.guard,
|
|
53
|
+
effect: t.effect,
|
|
54
|
+
dependencies: t.dependencies ?? [],
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
57
|
/**
|
|
@@ -65,13 +76,12 @@ function normalizeDefinition(def) {
|
|
|
65
76
|
/**
|
|
66
77
|
* Normalize a CreateStateMachine message for wire format
|
|
67
78
|
*
|
|
68
|
-
* Ensures all Option fields are explicit
|
|
69
|
-
* - definition.metadata
|
|
70
|
-
* - definition.states[*].metadata
|
|
71
|
-
* - definition.transitions[*].
|
|
72
|
-
* -
|
|
73
|
-
* -
|
|
74
|
-
* - parentFiberId
|
|
79
|
+
* Ensures all Option/default fields are explicit in wire format:
|
|
80
|
+
* - definition.metadata → null when absent
|
|
81
|
+
* - definition.states[*].metadata → null when absent
|
|
82
|
+
* - definition.transitions[*].dependencies → [] when absent
|
|
83
|
+
* - parentFiberId → null when absent
|
|
84
|
+
* - participants → null when absent (Optional Set[Address] for multi-party signing)
|
|
75
85
|
*
|
|
76
86
|
* @example
|
|
77
87
|
* ```typescript
|
|
@@ -80,7 +90,7 @@ function normalizeDefinition(def) {
|
|
|
80
90
|
* definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
|
|
81
91
|
* initialData: {}
|
|
82
92
|
* });
|
|
83
|
-
* // message now has parentFiberId: null, definition.metadata: null, etc.
|
|
93
|
+
* // message now has parentFiberId: null, participants: null, definition.metadata: null, etc.
|
|
84
94
|
* ```
|
|
85
95
|
*/
|
|
86
96
|
function normalizeCreateStateMachine(msg) {
|
|
@@ -89,6 +99,7 @@ function normalizeCreateStateMachine(msg) {
|
|
|
89
99
|
definition: normalizeDefinition(msg.definition),
|
|
90
100
|
initialData: msg.initialData ?? {},
|
|
91
101
|
parentFiberId: msg.parentFiberId ?? null,
|
|
102
|
+
participants: msg.participants ?? null,
|
|
92
103
|
};
|
|
93
104
|
}
|
|
94
105
|
exports.normalizeCreateStateMachine = normalizeCreateStateMachine;
|
|
@@ -29,15 +29,26 @@ function normalizeState(state) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Normalize a Transition object for wire format
|
|
32
|
+
*
|
|
33
|
+
* Scala Transition schema:
|
|
34
|
+
* from: StateId (required)
|
|
35
|
+
* to: StateId (required)
|
|
36
|
+
* eventName: String (required)
|
|
37
|
+
* guard: JsonLogicExpression (required)
|
|
38
|
+
* effect: JsonLogicExpression (required)
|
|
39
|
+
* dependencies: Set[UUID] = Set.empty
|
|
40
|
+
*
|
|
41
|
+
* `dependencies` serializes as `[]` when empty (default). Both `guard`
|
|
42
|
+
* and `effect` are required non-optional fields.
|
|
32
43
|
*/
|
|
33
44
|
function normalizeTransition(t) {
|
|
34
45
|
return {
|
|
35
46
|
from: t.from,
|
|
36
|
-
eventName: t.eventName,
|
|
37
47
|
to: t.to,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
eventName: t.eventName,
|
|
49
|
+
guard: t.guard,
|
|
50
|
+
effect: t.effect,
|
|
51
|
+
dependencies: t.dependencies ?? [],
|
|
41
52
|
};
|
|
42
53
|
}
|
|
43
54
|
/**
|
|
@@ -62,13 +73,12 @@ function normalizeDefinition(def) {
|
|
|
62
73
|
/**
|
|
63
74
|
* Normalize a CreateStateMachine message for wire format
|
|
64
75
|
*
|
|
65
|
-
* Ensures all Option fields are explicit
|
|
66
|
-
* - definition.metadata
|
|
67
|
-
* - definition.states[*].metadata
|
|
68
|
-
* - definition.transitions[*].
|
|
69
|
-
* -
|
|
70
|
-
* -
|
|
71
|
-
* - parentFiberId
|
|
76
|
+
* Ensures all Option/default fields are explicit in wire format:
|
|
77
|
+
* - definition.metadata → null when absent
|
|
78
|
+
* - definition.states[*].metadata → null when absent
|
|
79
|
+
* - definition.transitions[*].dependencies → [] when absent
|
|
80
|
+
* - parentFiberId → null when absent
|
|
81
|
+
* - participants → null when absent (Optional Set[Address] for multi-party signing)
|
|
72
82
|
*
|
|
73
83
|
* @example
|
|
74
84
|
* ```typescript
|
|
@@ -77,7 +87,7 @@ function normalizeDefinition(def) {
|
|
|
77
87
|
* definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
|
|
78
88
|
* initialData: {}
|
|
79
89
|
* });
|
|
80
|
-
* // message now has parentFiberId: null, definition.metadata: null, etc.
|
|
90
|
+
* // message now has parentFiberId: null, participants: null, definition.metadata: null, etc.
|
|
81
91
|
* ```
|
|
82
92
|
*/
|
|
83
93
|
export function normalizeCreateStateMachine(msg) {
|
|
@@ -86,6 +96,7 @@ export function normalizeCreateStateMachine(msg) {
|
|
|
86
96
|
definition: normalizeDefinition(msg.definition),
|
|
87
97
|
initialData: msg.initialData ?? {},
|
|
88
98
|
parentFiberId: msg.parentFiberId ?? null,
|
|
99
|
+
participants: msg.participants ?? null,
|
|
89
100
|
};
|
|
90
101
|
}
|
|
91
102
|
/**
|
|
@@ -20,13 +20,12 @@
|
|
|
20
20
|
/**
|
|
21
21
|
* Normalize a CreateStateMachine message for wire format
|
|
22
22
|
*
|
|
23
|
-
* Ensures all Option fields are explicit
|
|
24
|
-
* - definition.metadata
|
|
25
|
-
* - definition.states[*].metadata
|
|
26
|
-
* - definition.transitions[*].
|
|
27
|
-
* -
|
|
28
|
-
* -
|
|
29
|
-
* - parentFiberId
|
|
23
|
+
* Ensures all Option/default fields are explicit in wire format:
|
|
24
|
+
* - definition.metadata → null when absent
|
|
25
|
+
* - definition.states[*].metadata → null when absent
|
|
26
|
+
* - definition.transitions[*].dependencies → [] when absent
|
|
27
|
+
* - parentFiberId → null when absent
|
|
28
|
+
* - participants → null when absent (Optional Set[Address] for multi-party signing)
|
|
30
29
|
*
|
|
31
30
|
* @example
|
|
32
31
|
* ```typescript
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
* definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
|
|
36
35
|
* initialData: {}
|
|
37
36
|
* });
|
|
38
|
-
* // message now has parentFiberId: null, definition.metadata: null, etc.
|
|
37
|
+
* // message now has parentFiberId: null, participants: null, definition.metadata: null, etc.
|
|
39
38
|
* ```
|
|
40
39
|
*/
|
|
41
40
|
export declare function normalizeCreateStateMachine(msg: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -157,7 +157,9 @@ export interface CreateStateMachine {
|
|
|
157
157
|
fiberId: string;
|
|
158
158
|
definition: StateMachineDefinition;
|
|
159
159
|
initialData: JsonLogicValue;
|
|
160
|
-
parentFiberId?: string;
|
|
160
|
+
parentFiberId?: string | null;
|
|
161
|
+
/** Optional set of DAG addresses authorized to sign transitions (multi-party signing). */
|
|
162
|
+
participants?: string[] | null;
|
|
161
163
|
}
|
|
162
164
|
/**
|
|
163
165
|
* Trigger a state machine transition.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ottochain/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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",
|
|
@@ -100,18 +100,18 @@
|
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@babel/preset-env": "^7.29.0",
|
|
102
102
|
"@commitlint/cli": "^20.4.4",
|
|
103
|
-
"@commitlint/config-conventional": "^
|
|
104
|
-
"@eslint/js": "^9.39.
|
|
103
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
104
|
+
"@eslint/js": "^9.39.4",
|
|
105
105
|
"@jest/globals": "^30.3.0",
|
|
106
106
|
"@types/jest": "^30.0.0",
|
|
107
|
-
"@types/node": "^25.
|
|
107
|
+
"@types/node": "^25.5.0",
|
|
108
108
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
109
|
-
"@typescript-eslint/parser": "^8.
|
|
109
|
+
"@typescript-eslint/parser": "^8.57.1",
|
|
110
110
|
"eslint": "^9.39.3",
|
|
111
|
-
"jest": "^30.
|
|
111
|
+
"jest": "^30.3.0",
|
|
112
112
|
"prettier": "^3.0.0",
|
|
113
113
|
"ts-jest": "^29.0.0",
|
|
114
|
-
"ts-proto": "^2.11.
|
|
114
|
+
"ts-proto": "^2.11.5",
|
|
115
115
|
"typedoc": "^0.28.17",
|
|
116
116
|
"typescript": "^5.0.0"
|
|
117
117
|
},
|