@ottochain/sdk 1.0.3 → 1.1.1

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 (181) hide show
  1. package/dist/cjs/apps/contracts/state-machines/contract.json +21 -63
  2. package/dist/cjs/apps/contracts/state-machines/escrow.json +23 -69
  3. package/dist/cjs/apps/governance/state-machines/dao-multisig.json +22 -66
  4. package/dist/cjs/apps/governance/state-machines/dao-single.json +14 -42
  5. package/dist/cjs/apps/governance/state-machines/dao-threshold.json +18 -54
  6. package/dist/cjs/apps/governance/state-machines/dao-token.json +21 -63
  7. package/dist/cjs/apps/governance/state-machines/governance-constitution.json +22 -66
  8. package/dist/cjs/apps/governance/state-machines/governance-executive.json +27 -81
  9. package/dist/cjs/apps/governance/state-machines/governance-judiciary.json +34 -102
  10. package/dist/cjs/apps/governance/state-machines/governance-legislature.json +32 -96
  11. package/dist/cjs/apps/governance/state-machines/governance-simple.json +27 -81
  12. package/dist/cjs/apps/identity/state-machines/agent-identity.json +25 -75
  13. package/dist/cjs/apps/markets/state-machines/market-universal.json +377 -110
  14. package/dist/cjs/apps/oracles/state-machines/oracle.json +22 -66
  15. package/dist/cjs/generated/index.js +11 -1
  16. package/dist/cjs/metakit/drop-nulls.js +50 -0
  17. package/dist/cjs/metakit/normalize.js +147 -0
  18. package/dist/cjs/ottochain/metagraph-client.js +147 -0
  19. package/dist/cjs/validation.js +1 -1
  20. package/dist/esm/apps/contracts/state-machines/contract.json +21 -63
  21. package/dist/esm/apps/contracts/state-machines/escrow.json +23 -69
  22. package/dist/esm/apps/governance/state-machines/dao-multisig.json +22 -66
  23. package/dist/esm/apps/governance/state-machines/dao-single.json +14 -42
  24. package/dist/esm/apps/governance/state-machines/dao-threshold.json +18 -54
  25. package/dist/esm/apps/governance/state-machines/dao-token.json +21 -63
  26. package/dist/esm/apps/governance/state-machines/governance-constitution.json +22 -66
  27. package/dist/esm/apps/governance/state-machines/governance-executive.json +27 -81
  28. package/dist/esm/apps/governance/state-machines/governance-judiciary.json +34 -102
  29. package/dist/esm/apps/governance/state-machines/governance-legislature.json +32 -96
  30. package/dist/esm/apps/governance/state-machines/governance-simple.json +27 -81
  31. package/dist/esm/apps/identity/state-machines/agent-identity.json +25 -75
  32. package/dist/esm/apps/markets/state-machines/market-universal.json +377 -110
  33. package/dist/esm/apps/oracles/state-machines/oracle.json +22 -66
  34. package/dist/esm/generated/index.js +11 -1
  35. package/dist/esm/metakit/drop-nulls.js +46 -0
  36. package/dist/esm/metakit/normalize.js +140 -0
  37. package/dist/esm/ottochain/metagraph-client.js +147 -0
  38. package/dist/esm/validation.js +1 -1
  39. package/dist/types/generated/index.d.ts +11 -1
  40. package/dist/types/metakit/drop-nulls.d.ts +29 -0
  41. package/dist/types/metakit/normalize.d.ts +67 -0
  42. package/dist/types/ottochain/index.d.ts +1 -1
  43. package/dist/types/ottochain/metagraph-client.d.ts +90 -0
  44. package/package.json +12 -12
  45. package/dist/apps/contracts/index.d.ts +0 -21
  46. package/dist/apps/contracts/index.js +0 -39
  47. package/dist/apps/contracts/types.d.ts +0 -24
  48. package/dist/apps/contracts/types.js +0 -48
  49. package/dist/apps/identity/index.d.ts +0 -22
  50. package/dist/apps/identity/index.js +0 -40
  51. package/dist/apps/identity/types.d.ts +0 -30
  52. package/dist/apps/identity/types.js +0 -53
  53. package/dist/apps/index.d.ts +0 -29
  54. package/dist/apps/index.js +0 -60
  55. package/dist/apps/markets/index.d.ts +0 -26
  56. package/dist/apps/markets/index.js +0 -46
  57. package/dist/apps/markets/types.d.ts +0 -185
  58. package/dist/apps/markets/types.js +0 -252
  59. package/dist/apps/oracles/index.d.ts +0 -26
  60. package/dist/apps/oracles/index.js +0 -46
  61. package/dist/apps/oracles/types.d.ts +0 -211
  62. package/dist/apps/oracles/types.js +0 -306
  63. package/dist/cjs/apps/contracts/types.js +0 -48
  64. package/dist/cjs/apps/corporate/types.js +0 -44
  65. package/dist/cjs/apps/governance/types.js +0 -42
  66. package/dist/cjs/apps/identity/types.js +0 -53
  67. package/dist/cjs/apps/markets/types.js +0 -219
  68. package/dist/cjs/apps/oracles/types.js +0 -282
  69. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -100
  70. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate_pb.js +0 -392
  71. package/dist/cjs/generated/ottochain/apps/governance/v1/governance_pb.js +0 -235
  72. package/dist/cjs/generated/ottochain/apps/identity/v1/agent_pb.js +0 -116
  73. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -79
  74. package/dist/cjs/generated/ottochain/apps/markets/v1/market_pb.js +0 -151
  75. package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -109
  76. package/dist/cjs/generated/ottochain/v1/common_pb.js +0 -37
  77. package/dist/cjs/generated/ottochain/v1/fiber_pb.js +0 -86
  78. package/dist/cjs/generated/ottochain/v1/messages_pb.js +0 -44
  79. package/dist/cjs/generated/ottochain/v1/records_pb.js +0 -44
  80. package/dist/errors.d.ts +0 -221
  81. package/dist/errors.js +0 -293
  82. package/dist/esm/apps/contracts/types.js +0 -44
  83. package/dist/esm/apps/corporate/types.js +0 -38
  84. package/dist/esm/apps/governance/types.js +0 -35
  85. package/dist/esm/apps/identity/types.js +0 -50
  86. package/dist/esm/apps/markets/types.js +0 -206
  87. package/dist/esm/apps/oracles/types.js +0 -267
  88. package/dist/esm/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -97
  89. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate_pb.js +0 -389
  90. package/dist/esm/generated/ottochain/apps/governance/v1/governance_pb.js +0 -232
  91. package/dist/esm/generated/ottochain/apps/identity/v1/agent_pb.js +0 -113
  92. package/dist/esm/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -76
  93. package/dist/esm/generated/ottochain/apps/markets/v1/market_pb.js +0 -148
  94. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -106
  95. package/dist/esm/generated/ottochain/v1/common_pb.js +0 -34
  96. package/dist/esm/generated/ottochain/v1/fiber_pb.js +0 -83
  97. package/dist/esm/generated/ottochain/v1/messages_pb.js +0 -41
  98. package/dist/esm/generated/ottochain/v1/records_pb.js +0 -41
  99. package/dist/generated/index.d.ts +0 -15
  100. package/dist/generated/index.js +0 -34
  101. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +0 -274
  102. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.js +0 -100
  103. package/dist/generated/ottochain/apps/identity/v1/agent_pb.d.ts +0 -211
  104. package/dist/generated/ottochain/apps/identity/v1/agent_pb.js +0 -116
  105. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +0 -238
  106. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.js +0 -79
  107. package/dist/generated/ottochain/apps/markets/v1/market_pb.d.ts +0 -436
  108. package/dist/generated/ottochain/apps/markets/v1/market_pb.js +0 -151
  109. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +0 -393
  110. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.js +0 -109
  111. package/dist/generated/ottochain/v1/common_pb.d.ts +0 -86
  112. package/dist/generated/ottochain/v1/common_pb.js +0 -37
  113. package/dist/generated/ottochain/v1/fiber_pb.d.ts +0 -292
  114. package/dist/generated/ottochain/v1/fiber_pb.js +0 -86
  115. package/dist/generated/ottochain/v1/messages_pb.d.ts +0 -190
  116. package/dist/generated/ottochain/v1/messages_pb.js +0 -44
  117. package/dist/generated/ottochain/v1/records_pb.d.ts +0 -221
  118. package/dist/generated/ottochain/v1/records_pb.js +0 -44
  119. package/dist/index.d.ts +0 -21
  120. package/dist/index.js +0 -77
  121. package/dist/metakit/binary.d.ts +0 -38
  122. package/dist/metakit/binary.js +0 -58
  123. package/dist/metakit/canonicalize.d.ts +0 -26
  124. package/dist/metakit/canonicalize.js +0 -40
  125. package/dist/metakit/codec.d.ts +0 -16
  126. package/dist/metakit/codec.js +0 -45
  127. package/dist/metakit/currency-transaction.d.ts +0 -157
  128. package/dist/metakit/currency-transaction.js +0 -319
  129. package/dist/metakit/currency-types.d.ts +0 -55
  130. package/dist/metakit/currency-types.js +0 -13
  131. package/dist/metakit/hash.d.ts +0 -50
  132. package/dist/metakit/hash.js +0 -84
  133. package/dist/metakit/index.d.ts +0 -23
  134. package/dist/metakit/index.js +0 -74
  135. package/dist/metakit/network/client.d.ts +0 -23
  136. package/dist/metakit/network/client.js +0 -78
  137. package/dist/metakit/network/currency-l1-client.d.ts +0 -71
  138. package/dist/metakit/network/currency-l1-client.js +0 -101
  139. package/dist/metakit/network/data-l1-client.d.ts +0 -57
  140. package/dist/metakit/network/data-l1-client.js +0 -76
  141. package/dist/metakit/network/index.d.ts +0 -10
  142. package/dist/metakit/network/index.js +0 -16
  143. package/dist/metakit/network/types.d.ts +0 -74
  144. package/dist/metakit/network/types.js +0 -20
  145. package/dist/metakit/sign.d.ts +0 -65
  146. package/dist/metakit/sign.js +0 -120
  147. package/dist/metakit/signed-object.d.ts +0 -66
  148. package/dist/metakit/signed-object.js +0 -100
  149. package/dist/metakit/types.d.ts +0 -67
  150. package/dist/metakit/types.js +0 -14
  151. package/dist/metakit/verify.d.ts +0 -55
  152. package/dist/metakit/verify.js +0 -217
  153. package/dist/metakit/wallet.d.ts +0 -70
  154. package/dist/metakit/wallet.js +0 -127
  155. package/dist/ottochain/index.d.ts +0 -13
  156. package/dist/ottochain/index.js +0 -45
  157. package/dist/ottochain/metagraph-client.d.ts +0 -111
  158. package/dist/ottochain/metagraph-client.js +0 -157
  159. package/dist/ottochain/snapshot.d.ts +0 -86
  160. package/dist/ottochain/snapshot.js +0 -110
  161. package/dist/ottochain/types.d.ts +0 -278
  162. package/dist/ottochain/types.js +0 -11
  163. package/dist/types/apps/contracts/types.d.ts +0 -24
  164. package/dist/types/apps/corporate/types.d.ts +0 -9861
  165. package/dist/types/apps/governance/types.d.ts +0 -344
  166. package/dist/types/apps/identity/types.d.ts +0 -30
  167. package/dist/types/apps/markets/types.d.ts +0 -155
  168. package/dist/types/apps/oracles/types.d.ts +0 -193
  169. package/dist/types/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +0 -274
  170. package/dist/types/generated/ottochain/apps/corporate/v1/corporate_pb.d.ts +0 -1172
  171. package/dist/types/generated/ottochain/apps/governance/v1/governance_pb.d.ts +0 -772
  172. package/dist/types/generated/ottochain/apps/identity/v1/agent_pb.d.ts +0 -211
  173. package/dist/types/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +0 -238
  174. package/dist/types/generated/ottochain/apps/markets/v1/market_pb.d.ts +0 -436
  175. package/dist/types/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +0 -393
  176. package/dist/types/generated/ottochain/v1/common_pb.d.ts +0 -86
  177. package/dist/types/generated/ottochain/v1/fiber_pb.d.ts +0 -292
  178. package/dist/types/generated/ottochain/v1/messages_pb.d.ts +0 -190
  179. package/dist/types/generated/ottochain/v1/records_pb.d.ts +0 -221
  180. package/dist/validation.d.ts +0 -449
  181. package/dist/validation.js +0 -312
@@ -16,6 +16,45 @@ export interface Checkpoint {
16
16
  ordinal: number;
17
17
  state: CalculatedState;
18
18
  }
19
+ /**
20
+ * Options for subscribeFiberState polling behaviour.
21
+ */
22
+ export interface SubscribeOptions {
23
+ /**
24
+ * Polling interval in milliseconds.
25
+ * @default 2000
26
+ */
27
+ pollIntervalMs?: number;
28
+ /**
29
+ * Called when a poll fails (network error, timeout, etc.) or when the
30
+ * user-supplied callback throws. The subscription continues after an error.
31
+ * @default (e) => console.warn('[subscribeFiberState]', e)
32
+ */
33
+ onError?: (error: Error) => void;
34
+ /**
35
+ * If true, fire the callback immediately after the very first poll even
36
+ * when no previous state exists (current vs. null).
37
+ * Set false to suppress the initial callback and only fire on changes.
38
+ *
39
+ * **Edge case:** When `fireImmediately` is false and the fiber never exists
40
+ * (getStateMachine always returns null), the callback will never fire because
41
+ * the sequence number stays null between polls (no change detected).
42
+ * @default true
43
+ */
44
+ fireImmediately?: boolean;
45
+ }
46
+ /**
47
+ * Callback invoked when fiber state is first observed or changes.
48
+ *
49
+ * @param current - Current fiber state, or null if fiber not found
50
+ * @param previous - Previous fiber state, or null on first callback
51
+ */
52
+ export type FiberStateCallback = (current: StateMachineFiberRecord | null, previous: StateMachineFiberRecord | null) => void;
53
+ /**
54
+ * Unsubscribe function returned by subscribeFiberState.
55
+ * Stops polling immediately and prevents any further callbacks. Idempotent.
56
+ */
57
+ export type Unsubscribe = () => void;
19
58
  /**
20
59
  * Configuration for the MetagraphClient.
21
60
  */
@@ -98,6 +137,57 @@ export declare class MetagraphClient {
98
137
  * Get the latest snapshot ordinal.
99
138
  */
100
139
  getLatestOrdinal(): Promise<number>;
140
+ /**
141
+ * Subscribe to state changes for a state machine fiber.
142
+ *
143
+ * Polls ML0 at the configured interval and compares `sequenceNumber` to
144
+ * detect changes. Fires the callback with `(current, previous)` on the
145
+ * first poll (if `fireImmediately` is true — the default) and on every
146
+ * subsequent change.
147
+ *
148
+ * ML0 consistency: state is read from snapshot-level `CalculatedState`
149
+ * (via `checkpointService.get`), so a poll never returns a mid-transition
150
+ * value — every observation is a fully committed state.
151
+ *
152
+ * Uses `setTimeout` recursion to prevent overlapping polls when a request
153
+ * takes longer than `pollIntervalMs`.
154
+ *
155
+ * @param fiberId - UUID of the state machine fiber to watch
156
+ * @param callback - Called on first observation and on every state change
157
+ * @param options - Polling interval, error handler, fireImmediately flag
158
+ * @returns Unsubscribe function — call to stop polling immediately
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * const unsub = client.subscribeFiberState(fiberId, (current, prev) => {
163
+ * if (current?.currentState === 'Completed') {
164
+ * unsub();
165
+ * }
166
+ * });
167
+ * // Later:
168
+ * unsub();
169
+ * ```
170
+ */
171
+ subscribeFiberState(fiberId: string, callback: FiberStateCallback, options?: SubscribeOptions): Unsubscribe;
172
+ /**
173
+ * Wait for a fiber to reach a specific state, with an optional timeout.
174
+ *
175
+ * Builds on `subscribeFiberState` — resolves with the fiber record once
176
+ * `currentState === targetState`, or resolves with `null` after `timeoutMs`.
177
+ * Always calls unsubscribe on resolution or timeout (no memory leaks).
178
+ *
179
+ * @param fiberId - UUID of the state machine fiber
180
+ * @param targetState - State name to wait for (e.g. `'Completed'`)
181
+ * @param timeoutMs - Maximum wait in milliseconds (default: 30 000)
182
+ * @returns Fiber record when target state reached, or `null` on timeout
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const result = await client.waitForState(fiberId, 'Completed', 15_000);
187
+ * if (result === null) console.warn('Timed out waiting for Completed');
188
+ * ```
189
+ */
190
+ waitForState(fiberId: string, targetState: string, timeoutMs?: number, options?: Pick<SubscribeOptions, 'pollIntervalMs' | 'onError'>): Promise<StateMachineFiberRecord | null>;
101
191
  /**
102
192
  * Submit a signed data update to the DL1 node.
103
193
  * The POST /data endpoint is framework-provided (no /v1 prefix).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottochain/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
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",
@@ -55,6 +55,11 @@
55
55
  "import": "./dist/esm/apps/index.js",
56
56
  "require": "./dist/cjs/apps/index.js",
57
57
  "types": "./dist/types/apps/index.d.ts"
58
+ },
59
+ "./generated": {
60
+ "import": "./dist/esm/generated/index.js",
61
+ "require": "./dist/cjs/generated/index.js",
62
+ "types": "./dist/types/generated/index.d.ts"
58
63
  }
59
64
  },
60
65
  "files": [
@@ -107,21 +112,16 @@
107
112
  "zod": "^3.22.0"
108
113
  },
109
114
  "devDependencies": {
110
- "@bufbuild/buf": "^1.65.0",
111
- "@bufbuild/protoc-gen-es": "^2.11.0",
112
- "@protobuf-ts/plugin": "^2.11.1",
113
- "@protobuf-ts/runtime": "^2.11.1",
114
- "@types/jest": "^29.5.0",
115
+ "@types/jest": "^30.0.0",
115
116
  "@types/node": "^20.0.0",
116
- "@typescript-eslint/eslint-plugin": "^7.0.0",
117
- "@typescript-eslint/parser": "^7.0.0",
118
- "eslint": "^8.0.0",
119
- "grpc-tools": "^1.13.1",
120
- "jest": "^29.0.0",
117
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
118
+ "@typescript-eslint/parser": "^8.56.1",
119
+ "eslint": "^9.39.3",
120
+ "jest": "^30.2.0",
121
121
  "prettier": "^3.0.0",
122
122
  "ts-jest": "^29.0.0",
123
123
  "ts-proto": "^2.11.2",
124
- "typedoc": "^0.25.0",
124
+ "typedoc": "^0.28.17",
125
125
  "typescript": "^5.0.0"
126
126
  },
127
127
  "peerDependencies": {
@@ -1,21 +0,0 @@
1
- /**
2
- * Contracts Application
3
- *
4
- * Types and utilities for the Contract system on OttoChain.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { ContractState, ContractSchema } from '@ottochain/sdk/apps/contracts';
9
- * import { create } from '@bufbuild/protobuf';
10
- *
11
- * const contract = create(ContractSchema, {
12
- * id: 'fiber-123',
13
- * contractId: 'contract-001',
14
- * state: ContractState.PROPOSED,
15
- * });
16
- * ```
17
- *
18
- * @packageDocumentation
19
- */
20
- export * from '../../generated/ottochain/apps/contracts/v1/contract_pb.js';
21
- export * from './types.js';
@@ -1,39 +0,0 @@
1
- "use strict";
2
- /**
3
- * Contracts Application
4
- *
5
- * Types and utilities for the Contract system on OttoChain.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { ContractState, ContractSchema } from '@ottochain/sdk/apps/contracts';
10
- * import { create } from '@bufbuild/protobuf';
11
- *
12
- * const contract = create(ContractSchema, {
13
- * id: 'fiber-123',
14
- * contractId: 'contract-001',
15
- * state: ContractState.PROPOSED,
16
- * });
17
- * ```
18
- *
19
- * @packageDocumentation
20
- */
21
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- var desc = Object.getOwnPropertyDescriptor(m, k);
24
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
- desc = { enumerable: true, get: function() { return m[k]; } };
26
- }
27
- Object.defineProperty(o, k2, desc);
28
- }) : (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
30
- o[k2] = m[k];
31
- }));
32
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
33
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- // Re-export generated protobuf types
37
- __exportStar(require("../../generated/ottochain/apps/contracts/v1/contract_pb.js"), exports);
38
- // Re-export convenience types and constants
39
- __exportStar(require("./types.js"), exports);
@@ -1,24 +0,0 @@
1
- /**
2
- * Contract Utilities
3
- *
4
- * Constants and utilities for the Contract application.
5
- * Core types are generated from protobuf - see the generated exports.
6
- *
7
- * @packageDocumentation
8
- */
9
- import { ContractState } from '../../generated/ottochain/apps/contracts/v1/contract_pb.js';
10
- /**
11
- * Default contract configuration
12
- */
13
- export declare const DEFAULT_CONTRACT_CONFIG: {
14
- readonly requireBothSignatures: false;
15
- readonly disputeWindowEpochs: 10;
16
- };
17
- /**
18
- * Valid transitions for each contract state
19
- */
20
- export declare const CONTRACT_TRANSITIONS: Record<ContractState, readonly string[]>;
21
- /**
22
- * Check if a contract state is terminal (no further transitions allowed)
23
- */
24
- export declare function isTerminalState(state: ContractState): boolean;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /**
3
- * Contract Utilities
4
- *
5
- * Constants and utilities for the Contract application.
6
- * Core types are generated from protobuf - see the generated exports.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isTerminalState = exports.CONTRACT_TRANSITIONS = exports.DEFAULT_CONTRACT_CONFIG = void 0;
12
- const contract_pb_js_1 = require("../../generated/ottochain/apps/contracts/v1/contract_pb.js");
13
- // ---------------------------------------------------------------------------
14
- // Configuration Defaults
15
- // ---------------------------------------------------------------------------
16
- /**
17
- * Default contract configuration
18
- */
19
- exports.DEFAULT_CONTRACT_CONFIG = {
20
- requireBothSignatures: false,
21
- disputeWindowEpochs: 10,
22
- };
23
- // ---------------------------------------------------------------------------
24
- // State Machine Transitions
25
- // ---------------------------------------------------------------------------
26
- /**
27
- * Valid transitions for each contract state
28
- */
29
- exports.CONTRACT_TRANSITIONS = {
30
- [contract_pb_js_1.ContractState.UNSPECIFIED]: [],
31
- [contract_pb_js_1.ContractState.PROPOSED]: ['accept', 'reject', 'cancel'],
32
- [contract_pb_js_1.ContractState.ACTIVE]: ['complete', 'dispute'],
33
- [contract_pb_js_1.ContractState.DISPUTED]: ['resolve_for_completer', 'resolve_for_disputant'],
34
- [contract_pb_js_1.ContractState.COMPLETED]: [], // Terminal state
35
- [contract_pb_js_1.ContractState.REJECTED]: [], // Terminal state
36
- [contract_pb_js_1.ContractState.CANCELLED]: [], // Terminal state
37
- };
38
- /**
39
- * Check if a contract state is terminal (no further transitions allowed)
40
- */
41
- function isTerminalState(state) {
42
- return [
43
- contract_pb_js_1.ContractState.COMPLETED,
44
- contract_pb_js_1.ContractState.REJECTED,
45
- contract_pb_js_1.ContractState.CANCELLED,
46
- ].includes(state);
47
- }
48
- exports.isTerminalState = isTerminalState;
@@ -1,22 +0,0 @@
1
- /**
2
- * Agent Identity Application
3
- *
4
- * Types and utilities for the Agent Identity system on OttoChain.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
9
- * import { create } from '@bufbuild/protobuf';
10
- *
11
- * const agent = create(AgentIdentitySchema, {
12
- * publicKey: '...',
13
- * reputation: 10,
14
- * state: AgentState.REGISTERED,
15
- * });
16
- * ```
17
- *
18
- * @packageDocumentation
19
- */
20
- export * from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
21
- export * from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
22
- export * from './types.js';
@@ -1,40 +0,0 @@
1
- "use strict";
2
- /**
3
- * Agent Identity Application
4
- *
5
- * Types and utilities for the Agent Identity system on OttoChain.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
10
- * import { create } from '@bufbuild/protobuf';
11
- *
12
- * const agent = create(AgentIdentitySchema, {
13
- * publicKey: '...',
14
- * reputation: 10,
15
- * state: AgentState.REGISTERED,
16
- * });
17
- * ```
18
- *
19
- * @packageDocumentation
20
- */
21
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- var desc = Object.getOwnPropertyDescriptor(m, k);
24
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
- desc = { enumerable: true, get: function() { return m[k]; } };
26
- }
27
- Object.defineProperty(o, k2, desc);
28
- }) : (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
30
- o[k2] = m[k];
31
- }));
32
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
33
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- // Re-export generated protobuf types
37
- __exportStar(require("../../generated/ottochain/apps/identity/v1/agent_pb.js"), exports);
38
- __exportStar(require("../../generated/ottochain/apps/identity/v1/attestation_pb.js"), exports);
39
- // Re-export convenience types and constants
40
- __exportStar(require("./types.js"), exports);
@@ -1,30 +0,0 @@
1
- /**
2
- * Agent Identity Utilities
3
- *
4
- * Constants and utilities for the Agent Identity application.
5
- * Core types are generated from protobuf - see the generated exports.
6
- *
7
- * @packageDocumentation
8
- */
9
- import { AgentState } from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
10
- import { AttestationType } from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
11
- /**
12
- * Default reputation configuration for agent identity
13
- */
14
- export declare const DEFAULT_REPUTATION_CONFIG: {
15
- readonly baseReputation: 10;
16
- readonly completionDelta: 5;
17
- readonly vouchDelta: 2;
18
- readonly violationDelta: -10;
19
- readonly behavioralDelta: 3;
20
- readonly minReputation: 0;
21
- readonly challengeThreshold: 5;
22
- };
23
- /**
24
- * Valid transitions for each agent state
25
- */
26
- export declare const AGENT_TRANSITIONS: Record<AgentState, readonly string[]>;
27
- /**
28
- * Reputation delta by attestation type
29
- */
30
- export declare const ATTESTATION_DELTAS: Record<AttestationType, number>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- /**
3
- * Agent Identity Utilities
4
- *
5
- * Constants and utilities for the Agent Identity application.
6
- * Core types are generated from protobuf - see the generated exports.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ATTESTATION_DELTAS = exports.AGENT_TRANSITIONS = exports.DEFAULT_REPUTATION_CONFIG = void 0;
12
- const agent_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/agent_pb.js");
13
- const attestation_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/attestation_pb.js");
14
- // ---------------------------------------------------------------------------
15
- // Configuration Defaults
16
- // ---------------------------------------------------------------------------
17
- /**
18
- * Default reputation configuration for agent identity
19
- */
20
- exports.DEFAULT_REPUTATION_CONFIG = {
21
- baseReputation: 10,
22
- completionDelta: 5,
23
- vouchDelta: 2,
24
- violationDelta: -10,
25
- behavioralDelta: 3,
26
- minReputation: 0,
27
- challengeThreshold: 5,
28
- };
29
- // ---------------------------------------------------------------------------
30
- // State Machine Transitions
31
- // ---------------------------------------------------------------------------
32
- /**
33
- * Valid transitions for each agent state
34
- */
35
- exports.AGENT_TRANSITIONS = {
36
- [agent_pb_js_1.AgentState.UNSPECIFIED]: [],
37
- [agent_pb_js_1.AgentState.REGISTERED]: ['activate', 'withdraw'],
38
- [agent_pb_js_1.AgentState.ACTIVE]: ['challenge', 'withdraw'],
39
- [agent_pb_js_1.AgentState.CHALLENGED]: ['uphold_challenge', 'dismiss_challenge'],
40
- [agent_pb_js_1.AgentState.SUSPENDED]: ['begin_probation'],
41
- [agent_pb_js_1.AgentState.PROBATION]: ['complete_probation'],
42
- [agent_pb_js_1.AgentState.WITHDRAWN]: [], // Terminal state
43
- };
44
- /**
45
- * Reputation delta by attestation type
46
- */
47
- exports.ATTESTATION_DELTAS = {
48
- [attestation_pb_js_1.AttestationType.UNSPECIFIED]: 0,
49
- [attestation_pb_js_1.AttestationType.COMPLETION]: 5,
50
- [attestation_pb_js_1.AttestationType.VOUCH]: 2,
51
- [attestation_pb_js_1.AttestationType.VIOLATION]: -10,
52
- [attestation_pb_js_1.AttestationType.BEHAVIORAL]: 3,
53
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * OttoChain Applications
3
- *
4
- * Application-specific types and utilities for OttoChain SDK.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
9
- *
10
- * // Use identity types
11
- * const { AgentState, AGENT_TRANSITIONS } = identity;
12
- *
13
- * // Use market calculations
14
- * const payout = markets.calculatePayout(shares);
15
- *
16
- * // Check oracle reputation
17
- * const newRep = oracles.calculateReputation(current, delta);
18
- * ```
19
- *
20
- * @packageDocumentation
21
- */
22
- export * as identity from './identity/index.js';
23
- export * as contracts from './contracts/index.js';
24
- export * as markets from './markets/index.js';
25
- export * as oracles from './oracles/index.js';
26
- export * from './identity/index.js';
27
- export * from './contracts/index.js';
28
- export * from './markets/index.js';
29
- export * from './oracles/index.js';
@@ -1,60 +0,0 @@
1
- "use strict";
2
- /**
3
- * OttoChain Applications
4
- *
5
- * Application-specific types and utilities for OttoChain SDK.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
10
- *
11
- * // Use identity types
12
- * const { AgentState, AGENT_TRANSITIONS } = identity;
13
- *
14
- * // Use market calculations
15
- * const payout = markets.calculatePayout(shares);
16
- *
17
- * // Check oracle reputation
18
- * const newRep = oracles.calculateReputation(current, delta);
19
- * ```
20
- *
21
- * @packageDocumentation
22
- */
23
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- var desc = Object.getOwnPropertyDescriptor(m, k);
26
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
- desc = { enumerable: true, get: function() { return m[k]; } };
28
- }
29
- Object.defineProperty(o, k2, desc);
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
47
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.oracles = exports.markets = exports.contracts = exports.identity = void 0;
51
- // Re-export as namespaces for organized access
52
- exports.identity = __importStar(require("./identity/index.js"));
53
- exports.contracts = __importStar(require("./contracts/index.js"));
54
- exports.markets = __importStar(require("./markets/index.js"));
55
- exports.oracles = __importStar(require("./oracles/index.js"));
56
- // Also allow direct imports
57
- __exportStar(require("./identity/index.js"), exports);
58
- __exportStar(require("./contracts/index.js"), exports);
59
- __exportStar(require("./markets/index.js"), exports);
60
- __exportStar(require("./oracles/index.js"), exports);
@@ -1,26 +0,0 @@
1
- /**
2
- * Markets Application
3
- *
4
- * Types and utilities for the Markets system on OttoChain.
5
- * Supports prediction markets, auctions, crowdfunding, and group buys.
6
- *
7
- * @example
8
- * ```typescript
9
- * import {
10
- * MarketState,
11
- * MarketType,
12
- * calculatePayout,
13
- * DEFAULT_MARKET_CONFIG
14
- * } from '@ottochain/sdk/apps/markets';
15
- *
16
- * // Calculate payout for a winning prediction
17
- * const payout = calculatePayout({
18
- * winningPool: 1000n,
19
- * losingPool: 500n,
20
- * userCommitment: 100n,
21
- * });
22
- * ```
23
- *
24
- * @packageDocumentation
25
- */
26
- export * from './types.js';
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * Markets Application
4
- *
5
- * Types and utilities for the Markets system on OttoChain.
6
- * Supports prediction markets, auctions, crowdfunding, and group buys.
7
- *
8
- * @example
9
- * ```typescript
10
- * import {
11
- * MarketState,
12
- * MarketType,
13
- * calculatePayout,
14
- * DEFAULT_MARKET_CONFIG
15
- * } from '@ottochain/sdk/apps/markets';
16
- *
17
- * // Calculate payout for a winning prediction
18
- * const payout = calculatePayout({
19
- * winningPool: 1000n,
20
- * losingPool: 500n,
21
- * userCommitment: 100n,
22
- * });
23
- * ```
24
- *
25
- * @packageDocumentation
26
- */
27
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
- if (k2 === undefined) k2 = k;
29
- var desc = Object.getOwnPropertyDescriptor(m, k);
30
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
- desc = { enumerable: true, get: function() { return m[k]; } };
32
- }
33
- Object.defineProperty(o, k2, desc);
34
- }) : (function(o, m, k, k2) {
35
- if (k2 === undefined) k2 = k;
36
- o[k2] = m[k];
37
- }));
38
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
39
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- // Note: Once proto files are generated, uncomment these exports:
43
- // export * from '../../generated/ottochain/apps/markets/v1/market_pb.js';
44
- // export * from '../../generated/ottochain/apps/markets/v1/commitment_pb.js';
45
- // Export convenience types, constants, and helpers
46
- __exportStar(require("./types.js"), exports);