@ottochain/sdk 1.4.2 → 1.6.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.
- package/dist/cjs/apps/contracts/index.js +6 -10
- package/dist/cjs/apps/{governance/state-machines/governance-legislature.json → contracts/state-machines/index.js} +381 -330
- package/dist/cjs/apps/corporate/index.js +12 -24
- package/dist/cjs/apps/corporate/state-machines/index.js +10246 -0
- package/dist/cjs/apps/governance/index.js +11 -22
- package/dist/cjs/apps/governance/state-machines/index.js +4755 -0
- package/dist/cjs/apps/identity/index.js +3 -6
- package/dist/{esm/apps/identity/state-machines/agent-identity.json → cjs/apps/identity/state-machines/index.js} +9 -2
- package/dist/cjs/apps/markets/index.js +2 -5
- package/dist/{esm/apps/markets/state-machines/market-universal.json → cjs/apps/markets/state-machines/index.js} +9 -2
- package/dist/cjs/apps/oracles/index.js +2 -5
- package/dist/{esm/apps/oracles/state-machines/oracle.json → cjs/apps/oracles/state-machines/index.js} +9 -2
- package/dist/cjs/ottochain/index.js +4 -1
- package/dist/cjs/ottochain/normalize.js +40 -15
- package/dist/cjs/ottochain/types.js +12 -0
- package/dist/esm/apps/contracts/index.js +2 -3
- package/dist/esm/apps/{governance/state-machines/governance-legislature.json → contracts/state-machines/index.js} +378 -330
- package/dist/esm/apps/corporate/index.js +2 -11
- package/dist/esm/apps/corporate/state-machines/index.js +10243 -0
- package/dist/esm/apps/governance/index.js +2 -10
- package/dist/esm/apps/governance/state-machines/index.js +4752 -0
- package/dist/esm/apps/identity/index.js +2 -2
- package/dist/{cjs/apps/identity/state-machines/agent-identity.json → esm/apps/identity/state-machines/index.js} +6 -2
- package/dist/esm/apps/markets/index.js +1 -1
- package/dist/{cjs/apps/markets/state-machines/market-universal.json → esm/apps/markets/state-machines/index.js} +6 -2
- package/dist/esm/apps/oracles/index.js +1 -1
- package/dist/{cjs/apps/oracles/state-machines/oracle.json → esm/apps/oracles/state-machines/index.js} +6 -2
- package/dist/esm/ottochain/index.js +2 -0
- package/dist/esm/ottochain/normalize.js +40 -15
- package/dist/esm/ottochain/types.js +11 -1
- package/dist/types/apps/contracts/state-machines/index.d.ts +549 -0
- package/dist/types/apps/corporate/state-machines/index.d.ts +9121 -0
- package/dist/types/apps/governance/state-machines/index.d.ts +3551 -0
- package/dist/types/apps/identity/state-machines/index.d.ts +206 -0
- package/dist/types/apps/markets/state-machines/index.d.ts +448 -0
- package/dist/types/apps/oracles/state-machines/index.d.ts +312 -0
- package/dist/types/ottochain/index.d.ts +2 -1
- package/dist/types/ottochain/normalize.d.ts +21 -8
- package/dist/types/ottochain/types.d.ts +12 -1
- package/package.json +10 -9
- package/dist/cjs/apps/contracts/state-machines/contract.json +0 -352
- package/dist/cjs/apps/contracts/state-machines/escrow.json +0 -354
- package/dist/cjs/apps/corporate/state-machines/corporate-board.json +0 -1064
- package/dist/cjs/apps/corporate/state-machines/corporate-bylaws.json +0 -751
- package/dist/cjs/apps/corporate/state-machines/corporate-committee.json +0 -957
- package/dist/cjs/apps/corporate/state-machines/corporate-compliance.json +0 -1293
- package/dist/cjs/apps/corporate/state-machines/corporate-entity.json +0 -861
- package/dist/cjs/apps/corporate/state-machines/corporate-officers.json +0 -843
- package/dist/cjs/apps/corporate/state-machines/corporate-proxy.json +0 -783
- package/dist/cjs/apps/corporate/state-machines/corporate-resolution.json +0 -1174
- package/dist/cjs/apps/corporate/state-machines/corporate-securities.json +0 -1215
- package/dist/cjs/apps/corporate/state-machines/corporate-shareholders.json +0 -1298
- package/dist/cjs/apps/governance/state-machines/dao-multisig.json +0 -667
- package/dist/cjs/apps/governance/state-machines/dao-single.json +0 -230
- package/dist/cjs/apps/governance/state-machines/dao-threshold.json +0 -624
- package/dist/cjs/apps/governance/state-machines/dao-token.json +0 -638
- package/dist/cjs/apps/governance/state-machines/governance-constitution.json +0 -357
- package/dist/cjs/apps/governance/state-machines/governance-executive.json +0 -387
- package/dist/cjs/apps/governance/state-machines/governance-judiciary.json +0 -558
- package/dist/cjs/apps/governance/state-machines/governance-simple.json +0 -625
- package/dist/esm/apps/contracts/state-machines/contract.json +0 -352
- package/dist/esm/apps/contracts/state-machines/escrow.json +0 -354
- package/dist/esm/apps/corporate/state-machines/corporate-board.json +0 -1064
- package/dist/esm/apps/corporate/state-machines/corporate-bylaws.json +0 -751
- package/dist/esm/apps/corporate/state-machines/corporate-committee.json +0 -957
- package/dist/esm/apps/corporate/state-machines/corporate-compliance.json +0 -1293
- package/dist/esm/apps/corporate/state-machines/corporate-entity.json +0 -861
- package/dist/esm/apps/corporate/state-machines/corporate-officers.json +0 -843
- package/dist/esm/apps/corporate/state-machines/corporate-proxy.json +0 -783
- package/dist/esm/apps/corporate/state-machines/corporate-resolution.json +0 -1174
- package/dist/esm/apps/corporate/state-machines/corporate-securities.json +0 -1215
- package/dist/esm/apps/corporate/state-machines/corporate-shareholders.json +0 -1298
- package/dist/esm/apps/governance/state-machines/dao-multisig.json +0 -667
- package/dist/esm/apps/governance/state-machines/dao-single.json +0 -230
- package/dist/esm/apps/governance/state-machines/dao-threshold.json +0 -624
- package/dist/esm/apps/governance/state-machines/dao-token.json +0 -638
- package/dist/esm/apps/governance/state-machines/governance-constitution.json +0 -357
- package/dist/esm/apps/governance/state-machines/governance-executive.json +0 -387
- package/dist/esm/apps/governance/state-machines/governance-judiciary.json +0 -558
- package/dist/esm/apps/governance/state-machines/governance-simple.json +0 -625
|
@@ -37,9 +37,9 @@ export const DEFAULT_REPUTATION_CONFIG = {
|
|
|
37
37
|
challengeThreshold: 5,
|
|
38
38
|
};
|
|
39
39
|
// ---------------------------------------------------------------------------
|
|
40
|
-
// State Machine JSON
|
|
40
|
+
// State Machine Definition (generated from JSON at build time)
|
|
41
41
|
// ---------------------------------------------------------------------------
|
|
42
|
-
import agentIdentityDef from './state-machines/
|
|
42
|
+
import { agentIdentityDef } from './state-machines/index.js';
|
|
43
43
|
/**
|
|
44
44
|
* Get the agent identity state machine definition.
|
|
45
45
|
*
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated from JSON state machine definitions.
|
|
3
|
+
* DO NOT EDIT - regenerate with: npm run prebuild
|
|
4
|
+
*/
|
|
5
|
+
export const agentIdentityDef = {
|
|
2
6
|
"metadata": {
|
|
3
7
|
"name": "AgentIdentity",
|
|
4
8
|
"description": "Decentralized agent identity with reputation tracking and lifecycle management",
|
|
@@ -267,4 +271,4 @@
|
|
|
267
271
|
"dependencies": []
|
|
268
272
|
}
|
|
269
273
|
]
|
|
270
|
-
}
|
|
274
|
+
};
|
|
@@ -22,7 +22,7 @@ export { MarketType, MarketState, Commitment, Resolution, Market, CreateMarketRe
|
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
23
|
// State Machine JSON Definitions
|
|
24
24
|
// ---------------------------------------------------------------------------
|
|
25
|
-
import marketUniversalDef from './state-machines/
|
|
25
|
+
import { marketUniversalDef } from './state-machines/index.js';
|
|
26
26
|
export const MARKET_DEFINITIONS = {
|
|
27
27
|
Universal: marketUniversalDef,
|
|
28
28
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated from JSON state machine definitions.
|
|
3
|
+
* DO NOT EDIT - regenerate with: npm run prebuild
|
|
4
|
+
*/
|
|
5
|
+
export const marketUniversalDef = {
|
|
2
6
|
"metadata": {
|
|
3
7
|
"name": "Market",
|
|
4
8
|
"description": "Universal market state machine: predictions, auctions, crowdfunding, group buys",
|
|
@@ -618,4 +622,4 @@
|
|
|
618
622
|
"dependencies": []
|
|
619
623
|
}
|
|
620
624
|
]
|
|
621
|
-
}
|
|
625
|
+
};
|
|
@@ -22,7 +22,7 @@ export { OracleState, OracleReputation, SlashingEvent, Oracle, RegisterOracleReq
|
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
23
|
// State Machine JSON Definitions
|
|
24
24
|
// ---------------------------------------------------------------------------
|
|
25
|
-
import oracleDef from './state-machines/
|
|
25
|
+
import { oracleDef } from './state-machines/index.js';
|
|
26
26
|
export const ORACLE_DEFINITIONS = {
|
|
27
27
|
Oracle: oracleDef,
|
|
28
28
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated from JSON state machine definitions.
|
|
3
|
+
* DO NOT EDIT - regenerate with: npm run prebuild
|
|
4
|
+
*/
|
|
5
|
+
export const oracleDef = {
|
|
2
6
|
"metadata": {
|
|
3
7
|
"name": "Oracle",
|
|
4
8
|
"description": "Oracle registration, reputation, and slashing state machine",
|
|
@@ -405,4 +409,4 @@
|
|
|
405
409
|
"dependencies": []
|
|
406
410
|
}
|
|
407
411
|
]
|
|
408
|
-
}
|
|
412
|
+
};
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
// Re-export generated protobuf types (for binary encoding)
|
|
9
9
|
export * as proto from '../generated/index.js';
|
|
10
|
+
// Runtime message type validation
|
|
11
|
+
export { OTTOCHAIN_MESSAGE_TYPES } from './types.js';
|
|
10
12
|
export { decodeOnChainState, getSnapshotOnChainState, getLatestOnChainState, getLogsForFiber, getEventReceipts, getScriptInvocations, extractOnChainState, } from './snapshot.js';
|
|
11
13
|
export { MetagraphClient } from './metagraph-client.js';
|
|
12
14
|
// Transaction helpers (state machine payloads, signing)
|
|
@@ -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,26 +96,41 @@ 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
|
/**
|
|
92
103
|
* Normalize a TransitionStateMachine message for wire format
|
|
104
|
+
*
|
|
105
|
+
* Scala TransitionStateMachine schema:
|
|
106
|
+
* fiberId: UUID (required)
|
|
107
|
+
* eventName: String (required)
|
|
108
|
+
* payload: JsonLogicValue (required)
|
|
109
|
+
* targetSequenceNumber: FiberOrdinal (required)
|
|
110
|
+
*
|
|
111
|
+
* All fields are required — no Option types, so no null normalization needed.
|
|
93
112
|
*/
|
|
94
113
|
export function normalizeTransitionStateMachine(msg) {
|
|
95
114
|
return {
|
|
96
115
|
fiberId: msg.fiberId,
|
|
97
116
|
eventName: msg.eventName,
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
payload: msg.payload,
|
|
118
|
+
targetSequenceNumber: msg.targetSequenceNumber,
|
|
100
119
|
};
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
122
|
* Normalize an ArchiveStateMachine message for wire format
|
|
123
|
+
*
|
|
124
|
+
* Scala ArchiveStateMachine schema:
|
|
125
|
+
* fiberId: UUID (required)
|
|
126
|
+
* targetSequenceNumber: FiberOrdinal (required)
|
|
127
|
+
*
|
|
128
|
+
* All fields are required — no Option types, so no null normalization needed.
|
|
104
129
|
*/
|
|
105
130
|
export function normalizeArchiveStateMachine(msg) {
|
|
106
131
|
return {
|
|
107
132
|
fiberId: msg.fiberId,
|
|
108
|
-
|
|
133
|
+
targetSequenceNumber: msg.targetSequenceNumber,
|
|
109
134
|
};
|
|
110
135
|
}
|
|
111
136
|
/**
|
|
@@ -7,4 +7,14 @@
|
|
|
7
7
|
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Names of all valid OttochainMessage types.
|
|
12
|
+
* Use this for runtime validation (e.g., in API routes).
|
|
13
|
+
*/
|
|
14
|
+
export const OTTOCHAIN_MESSAGE_TYPES = [
|
|
15
|
+
'CreateStateMachine',
|
|
16
|
+
'TransitionStateMachine',
|
|
17
|
+
'ArchiveStateMachine',
|
|
18
|
+
'CreateScript',
|
|
19
|
+
'InvokeScript',
|
|
20
|
+
];
|