@ottochain/sdk 1.7.0-beta.2 → 2.1.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 (113) hide show
  1. package/dist/cjs/apps/contracts/index.js +1 -1
  2. package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +272 -0
  3. package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +284 -0
  4. package/dist/cjs/apps/contracts/state-machines/contract-universal.js +93 -0
  5. package/dist/cjs/apps/contracts/state-machines/index.js +177 -1
  6. package/dist/cjs/apps/corporate/state-machines/corp-board.js +1022 -0
  7. package/dist/cjs/apps/corporate/state-machines/corp-entity.js +671 -0
  8. package/dist/cjs/apps/corporate/state-machines/corp-securities.js +998 -0
  9. package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +1102 -0
  10. package/dist/cjs/apps/corporate/state-machines/index.js +20 -4440
  11. package/dist/cjs/apps/governance/index.js +7 -7
  12. package/dist/cjs/apps/governance/state-machines/dao-multisig.js +467 -0
  13. package/dist/cjs/apps/governance/state-machines/dao-reputation.js +458 -0
  14. package/dist/cjs/apps/governance/state-machines/dao-single.js +199 -0
  15. package/dist/cjs/apps/governance/state-machines/dao-token.js +503 -0
  16. package/dist/cjs/apps/governance/state-machines/governance-simple.js +482 -0
  17. package/dist/cjs/apps/governance/state-machines/governance-universal.js +138 -0
  18. package/dist/cjs/apps/governance/state-machines/index.js +16 -2934
  19. package/dist/cjs/apps/identity/constants.js +20 -20
  20. package/dist/cjs/apps/identity/index.js +13 -21
  21. package/dist/cjs/apps/identity/state-machines/identity-agent.js +256 -0
  22. package/dist/cjs/apps/identity/state-machines/identity-oracle.js +321 -0
  23. package/dist/cjs/apps/identity/state-machines/identity-universal.js +106 -0
  24. package/dist/cjs/apps/identity/state-machines/index.js +15 -784
  25. package/dist/cjs/apps/markets/index.js +1 -1
  26. package/dist/cjs/apps/markets/state-machines/index.js +14 -2298
  27. package/dist/cjs/apps/markets/state-machines/market-auction.js +283 -0
  28. package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +312 -0
  29. package/dist/cjs/apps/markets/state-machines/market-group-buy.js +407 -0
  30. package/dist/cjs/apps/markets/state-machines/market-prediction.js +485 -0
  31. package/dist/cjs/apps/markets/state-machines/market-universal.js +129 -0
  32. package/dist/cjs/apps/oracles/index.js +36 -0
  33. package/dist/cjs/generated/index.js +14 -7
  34. package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +197 -198
  35. package/dist/cjs/schema/fiber-app.js +55 -0
  36. package/dist/cjs/schema/index.js +20 -0
  37. package/dist/esm/apps/contracts/index.js +3 -3
  38. package/dist/esm/apps/contracts/state-machines/contract-agreement.js +269 -0
  39. package/dist/esm/apps/contracts/state-machines/contract-escrow.js +281 -0
  40. package/dist/esm/apps/contracts/state-machines/contract-universal.js +90 -0
  41. package/dist/esm/apps/contracts/state-machines/index.js +177 -1
  42. package/dist/esm/apps/corporate/index.js +3 -3
  43. package/dist/esm/apps/corporate/state-machines/corp-board.js +1019 -0
  44. package/dist/esm/apps/corporate/state-machines/corp-entity.js +668 -0
  45. package/dist/esm/apps/corporate/state-machines/corp-securities.js +995 -0
  46. package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +1099 -0
  47. package/dist/esm/apps/corporate/state-machines/index.js +15 -4439
  48. package/dist/esm/apps/governance/index.js +9 -9
  49. package/dist/esm/apps/governance/state-machines/dao-multisig.js +464 -0
  50. package/dist/esm/apps/governance/state-machines/dao-reputation.js +455 -0
  51. package/dist/esm/apps/governance/state-machines/dao-single.js +196 -0
  52. package/dist/esm/apps/governance/state-machines/dao-token.js +500 -0
  53. package/dist/esm/apps/governance/state-machines/governance-simple.js +479 -0
  54. package/dist/esm/apps/governance/state-machines/governance-universal.js +135 -0
  55. package/dist/esm/apps/governance/state-machines/index.js +9 -2933
  56. package/dist/esm/apps/identity/constants.js +21 -21
  57. package/dist/esm/apps/identity/index.js +13 -22
  58. package/dist/esm/apps/identity/state-machines/identity-agent.js +253 -0
  59. package/dist/esm/apps/identity/state-machines/identity-oracle.js +318 -0
  60. package/dist/esm/apps/identity/state-machines/identity-universal.js +103 -0
  61. package/dist/esm/apps/identity/state-machines/index.js +11 -783
  62. package/dist/esm/apps/index.js +5 -5
  63. package/dist/esm/apps/markets/index.js +3 -3
  64. package/dist/esm/apps/markets/state-machines/index.js +8 -2297
  65. package/dist/esm/apps/markets/state-machines/market-auction.js +280 -0
  66. package/dist/esm/apps/markets/state-machines/market-crowdfund.js +309 -0
  67. package/dist/esm/apps/markets/state-machines/market-group-buy.js +404 -0
  68. package/dist/esm/apps/markets/state-machines/market-prediction.js +482 -0
  69. package/dist/esm/apps/markets/state-machines/market-universal.js +126 -0
  70. package/dist/esm/apps/oracles/index.js +21 -0
  71. package/dist/esm/generated/index.js +8 -3
  72. package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +196 -197
  73. package/dist/esm/schema/fiber-app.js +47 -0
  74. package/dist/esm/schema/index.js +4 -0
  75. package/dist/types/apps/contracts/index.d.ts +151 -2
  76. package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +462 -0
  77. package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +511 -0
  78. package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +147 -0
  79. package/dist/types/apps/contracts/state-machines/index.d.ts +149 -0
  80. package/dist/types/apps/corporate/index.d.ts +5263 -3825
  81. package/dist/types/apps/corporate/state-machines/corp-board.d.ts +1479 -0
  82. package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +970 -0
  83. package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +1381 -0
  84. package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +1631 -0
  85. package/dist/types/apps/corporate/state-machines/index.d.ts +5245 -3802
  86. package/dist/types/apps/governance/index.d.ts +875 -37
  87. package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +644 -0
  88. package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +610 -0
  89. package/dist/types/apps/governance/state-machines/dao-single.d.ts +276 -0
  90. package/dist/types/apps/governance/state-machines/dao-token.d.ts +601 -0
  91. package/dist/types/apps/governance/state-machines/governance-simple.d.ts +652 -0
  92. package/dist/types/apps/governance/state-machines/governance-universal.d.ts +181 -0
  93. package/dist/types/apps/governance/state-machines/index.d.ts +9 -2136
  94. package/dist/types/apps/identity/constants.d.ts +4 -7
  95. package/dist/types/apps/identity/index.d.ts +1082 -592
  96. package/dist/types/apps/identity/state-machines/identity-agent.d.ts +401 -0
  97. package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +550 -0
  98. package/dist/types/apps/identity/state-machines/identity-universal.d.ts +151 -0
  99. package/dist/types/apps/identity/state-machines/index.d.ts +1069 -567
  100. package/dist/types/apps/index.d.ts +5 -5
  101. package/dist/types/apps/markets/index.d.ts +535 -7
  102. package/dist/types/apps/markets/state-machines/index.d.ts +8 -1678
  103. package/dist/types/apps/markets/state-machines/market-auction.d.ts +392 -0
  104. package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +443 -0
  105. package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +539 -0
  106. package/dist/types/apps/markets/state-machines/market-prediction.d.ts +651 -0
  107. package/dist/types/apps/markets/state-machines/market-universal.d.ts +191 -0
  108. package/dist/types/apps/oracles/index.d.ts +18 -0
  109. package/dist/types/generated/index.d.ts +3 -1
  110. package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +43 -64
  111. package/dist/types/schema/fiber-app.d.ts +139 -0
  112. package/dist/types/schema/index.d.ts +4 -0
  113. package/package.json +1 -1
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Minimal market state machine - extend for custom use cases.
3
+ */
4
+ export declare const marketUniversalDef: {
5
+ readonly metadata: {
6
+ readonly name: "MarketUniversal";
7
+ readonly app: "markets";
8
+ readonly type: "universal";
9
+ readonly version: "1.0.0";
10
+ readonly description: "Minimal market state machine - extend for custom use cases";
11
+ };
12
+ readonly createSchema: {
13
+ readonly properties: {};
14
+ };
15
+ readonly stateSchema: {
16
+ readonly properties: {
17
+ readonly status: {
18
+ readonly type: "string";
19
+ };
20
+ readonly totalCommitted: {
21
+ readonly type: "number";
22
+ readonly computed: true;
23
+ };
24
+ };
25
+ };
26
+ readonly eventSchemas: {
27
+ readonly open: {
28
+ readonly description: "Open the market for participation";
29
+ };
30
+ readonly cancel: {
31
+ readonly description: "Cancel the market";
32
+ };
33
+ readonly commit: {
34
+ readonly description: "Commit funds to the market";
35
+ readonly properties: {
36
+ readonly amount: {
37
+ readonly type: "number";
38
+ readonly minimum: 0;
39
+ };
40
+ };
41
+ };
42
+ readonly close: {
43
+ readonly description: "Close the market to new commits";
44
+ };
45
+ readonly settle: {
46
+ readonly description: "Settle the market";
47
+ };
48
+ };
49
+ readonly states: {
50
+ readonly PROPOSED: {
51
+ readonly id: "PROPOSED";
52
+ readonly isFinal: false;
53
+ readonly metadata: null;
54
+ };
55
+ readonly OPEN: {
56
+ readonly id: "OPEN";
57
+ readonly isFinal: false;
58
+ readonly metadata: null;
59
+ };
60
+ readonly CLOSED: {
61
+ readonly id: "CLOSED";
62
+ readonly isFinal: false;
63
+ readonly metadata: null;
64
+ };
65
+ readonly SETTLED: {
66
+ readonly id: "SETTLED";
67
+ readonly isFinal: true;
68
+ readonly metadata: null;
69
+ };
70
+ readonly CANCELLED: {
71
+ readonly id: "CANCELLED";
72
+ readonly isFinal: true;
73
+ readonly metadata: null;
74
+ };
75
+ };
76
+ readonly initialState: "PROPOSED";
77
+ readonly transitions: readonly [{
78
+ readonly from: "PROPOSED";
79
+ readonly to: "OPEN";
80
+ readonly eventName: "open";
81
+ readonly guard: {
82
+ readonly "==": readonly [1, 1];
83
+ };
84
+ readonly effect: {
85
+ readonly merge: readonly [{
86
+ readonly var: "state";
87
+ }, {
88
+ readonly status: "OPEN";
89
+ readonly openedAt: {
90
+ readonly var: "$timestamp";
91
+ };
92
+ }];
93
+ };
94
+ readonly dependencies: readonly [];
95
+ }, {
96
+ readonly from: "PROPOSED";
97
+ readonly to: "CANCELLED";
98
+ readonly eventName: "cancel";
99
+ readonly guard: {
100
+ readonly "==": readonly [1, 1];
101
+ };
102
+ readonly effect: {
103
+ readonly merge: readonly [{
104
+ readonly var: "state";
105
+ }, {
106
+ readonly status: "CANCELLED";
107
+ readonly cancelledAt: {
108
+ readonly var: "$timestamp";
109
+ };
110
+ }];
111
+ };
112
+ readonly dependencies: readonly [];
113
+ }, {
114
+ readonly from: "OPEN";
115
+ readonly to: "OPEN";
116
+ readonly eventName: "commit";
117
+ readonly guard: {
118
+ readonly ">": readonly [{
119
+ readonly var: "event.amount";
120
+ }, 0];
121
+ };
122
+ readonly effect: {
123
+ readonly merge: readonly [{
124
+ readonly var: "state";
125
+ }, {
126
+ readonly totalCommitted: {
127
+ readonly "+": readonly [{
128
+ readonly var: "state.totalCommitted";
129
+ }, {
130
+ readonly var: "event.amount";
131
+ }];
132
+ };
133
+ }];
134
+ };
135
+ readonly dependencies: readonly [];
136
+ }, {
137
+ readonly from: "OPEN";
138
+ readonly to: "CLOSED";
139
+ readonly eventName: "close";
140
+ readonly guard: {
141
+ readonly "==": readonly [1, 1];
142
+ };
143
+ readonly effect: {
144
+ readonly merge: readonly [{
145
+ readonly var: "state";
146
+ }, {
147
+ readonly status: "CLOSED";
148
+ readonly closedAt: {
149
+ readonly var: "$timestamp";
150
+ };
151
+ }];
152
+ };
153
+ readonly dependencies: readonly [];
154
+ }, {
155
+ readonly from: "CLOSED";
156
+ readonly to: "SETTLED";
157
+ readonly eventName: "settle";
158
+ readonly guard: {
159
+ readonly "==": readonly [1, 1];
160
+ };
161
+ readonly effect: {
162
+ readonly merge: readonly [{
163
+ readonly var: "state";
164
+ }, {
165
+ readonly status: "SETTLED";
166
+ readonly settledAt: {
167
+ readonly var: "$timestamp";
168
+ };
169
+ }];
170
+ };
171
+ readonly dependencies: readonly [];
172
+ }, {
173
+ readonly from: "CLOSED";
174
+ readonly to: "CANCELLED";
175
+ readonly eventName: "cancel";
176
+ readonly guard: {
177
+ readonly "==": readonly [1, 1];
178
+ };
179
+ readonly effect: {
180
+ readonly merge: readonly [{
181
+ readonly var: "state";
182
+ }, {
183
+ readonly status: "CANCELLED";
184
+ readonly cancelledAt: {
185
+ readonly var: "$timestamp";
186
+ };
187
+ }];
188
+ };
189
+ readonly dependencies: readonly [];
190
+ }];
191
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Oracle Application — Backward Compatibility Shim
3
+ *
4
+ * ⚠️ DEPRECATED: Oracle types have been unified into the Identity app.
5
+ * Import from `@ottochain/sdk/apps/identity` instead.
6
+ *
7
+ * @deprecated Use `@ottochain/sdk/apps/identity`
8
+ * @packageDocumentation
9
+ */
10
+ export { IdentityState as OracleState, Reputation as OracleReputation, PenaltyEvent as SlashingEvent, Identity as Oracle, RegisterIdentityRequest as RegisterOracleRequest, ActivateIdentityRequest as ActivateOracleRequest, AddStakeRequest, WithdrawIdentityRequest as WithdrawOracleRequest, IdentityDefinition as OracleDefinition, identityStateFromJSON as oracleStateFromJSON, identityStateToJSON as oracleStateToJSON, } from "../identity/index.js";
11
+ /** @deprecated Use `getIdentityDefinition('oracle')` from `@ottochain/sdk/apps/identity` */
12
+ export declare function getOracleDefinition(_type?: string): unknown;
13
+ /** @deprecated Use `DEFAULT_REPUTATION_CONFIG` from `@ottochain/sdk/apps/identity` */
14
+ export declare const DEFAULT_ORACLE_CONFIG: {
15
+ readonly minStake: 100;
16
+ readonly baseReputation: 10;
17
+ readonly reputationDecay: 0.95;
18
+ };
@@ -19,7 +19,9 @@
19
19
  export { FiberStatus, AccessControlPolicy, PublicAccess, WhitelistAccess, FiberOwnedAccess, StateMachineDefinition, EmittedEvent, EventReceipt, ScriptInvocation, FiberLogEntry, } from './ottochain/v1/fiber.js';
20
20
  export { CreateStateMachine, TransitionStateMachine, ArchiveStateMachine, CreateScript, InvokeScript, OttochainMessage, } from './ottochain/v1/messages.js';
21
21
  export { StateMachineFiberRecord, ScriptFiberRecord, FiberCommit, OnChainState, CalculatedState, } from './ottochain/v1/records.js';
22
- export { IdentityType, IdentityState, Platform, PlatformLink, Reputation, PenaltyEvent, Identity, RegisterIdentityRequest, ActivateIdentityRequest, UpdateStakeRequest, ChallengeIdentityRequest, PenalizeIdentityRequest, WithdrawIdentityRequest, IdentityDefinition, } from './ottochain/apps/identity/v1/identity.js';
22
+ export { IdentityType, IdentityState, Platform, PlatformLink, Reputation, PenaltyEvent, Identity, RegisterIdentityRequest, ActivateIdentityRequest, LinkPlatformRequest, ChallengeIdentityRequest, AddStakeRequest, WithdrawIdentityRequest, IdentityDefinition, } from './ottochain/apps/identity/v1/identity.js';
23
+ export { IdentityState as AgentState } from './ottochain/apps/identity/v1/identity.js';
24
+ export { IdentityState as OracleState } from './ottochain/apps/identity/v1/identity.js';
23
25
  export { AttestationType, ReputationDelta, Attestation, VouchRequest, ChallengeRequest, ReputationConfig, } from './ottochain/apps/identity/v1/attestation.js';
24
26
  export { ContractState, Contract, ProposeContractRequest, AcceptContractRequest, CompleteContractRequest, RejectContractRequest, DisputeContractRequest, ContractDefinition, } from './ottochain/apps/contracts/v1/contract.js';
25
27
  export { MarketType, MarketState, Commitment, Resolution, Market, CreateMarketRequest, CommitToMarketRequest, SubmitResolutionRequest, CancelMarketRequest, MarketDefinition, } from './ottochain/apps/markets/v1/market.js';
@@ -1,37 +1,42 @@
1
1
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
2
  export declare const protobufPackage = "ottochain.apps.identity.v1";
3
- /** Type of identity */
3
+ /** Identity type - determines which state machine variant applies */
4
4
  export declare enum IdentityType {
5
5
  IDENTITY_TYPE_UNSPECIFIED = "IDENTITY_TYPE_UNSPECIFIED",
6
- /** IDENTITY_TYPE_AGENT - General agent identity */
6
+ /** IDENTITY_TYPE_AGENT - AI agent identity */
7
7
  IDENTITY_TYPE_AGENT = "IDENTITY_TYPE_AGENT",
8
- /** IDENTITY_TYPE_ORACLE - Oracle service provider */
8
+ /** IDENTITY_TYPE_ORACLE - Oracle service identity */
9
9
  IDENTITY_TYPE_ORACLE = "IDENTITY_TYPE_ORACLE",
10
- /** IDENTITY_TYPE_SERVICE - Automated service identity */
10
+ /** IDENTITY_TYPE_SERVICE - Generic service identity */
11
11
  IDENTITY_TYPE_SERVICE = "IDENTITY_TYPE_SERVICE",
12
12
  UNRECOGNIZED = "UNRECOGNIZED"
13
13
  }
14
14
  export declare function identityTypeFromJSON(object: any): IdentityType;
15
15
  export declare function identityTypeToJSON(object: IdentityType): string;
16
16
  export declare function identityTypeToNumber(object: IdentityType): number;
17
- /** Identity lifecycle states (shared across all identity types) */
17
+ /**
18
+ * Unified identity lifecycle states
19
+ * Shared across all identity types with type-specific transitions
20
+ */
18
21
  export declare enum IdentityState {
19
22
  IDENTITY_STATE_UNSPECIFIED = "IDENTITY_STATE_UNSPECIFIED",
20
23
  /** IDENTITY_STATE_UNREGISTERED - Not yet registered (oracle initial) */
21
24
  IDENTITY_STATE_UNREGISTERED = "IDENTITY_STATE_UNREGISTERED",
22
- /** IDENTITY_STATE_REGISTERED - Registered, awaiting activation */
25
+ /** IDENTITY_STATE_REGISTERED - Registered, pending activation */
23
26
  IDENTITY_STATE_REGISTERED = "IDENTITY_STATE_REGISTERED",
24
27
  /** IDENTITY_STATE_ACTIVE - Active and participating */
25
28
  IDENTITY_STATE_ACTIVE = "IDENTITY_STATE_ACTIVE",
26
- /** IDENTITY_STATE_INACTIVE - Temporarily inactive */
27
- IDENTITY_STATE_INACTIVE = "IDENTITY_STATE_INACTIVE",
28
- /** IDENTITY_STATE_CHALLENGED - Under dispute/challenge */
29
+ /** IDENTITY_STATE_CHALLENGED - Under dispute (agent-specific) */
29
30
  IDENTITY_STATE_CHALLENGED = "IDENTITY_STATE_CHALLENGED",
30
- /** IDENTITY_STATE_SUSPENDED - Penalized (slashed for oracles) */
31
+ /** IDENTITY_STATE_SUSPENDED - Temporarily suspended */
31
32
  IDENTITY_STATE_SUSPENDED = "IDENTITY_STATE_SUSPENDED",
32
33
  /** IDENTITY_STATE_PROBATION - Recovering from suspension */
33
34
  IDENTITY_STATE_PROBATION = "IDENTITY_STATE_PROBATION",
34
- /** IDENTITY_STATE_WITHDRAWN - Voluntarily exited (terminal) */
35
+ /** IDENTITY_STATE_SLASHED - Penalized (oracle-specific) */
36
+ IDENTITY_STATE_SLASHED = "IDENTITY_STATE_SLASHED",
37
+ /** IDENTITY_STATE_INACTIVE - Voluntarily inactive but can reactivate */
38
+ IDENTITY_STATE_INACTIVE = "IDENTITY_STATE_INACTIVE",
39
+ /** IDENTITY_STATE_WITHDRAWN - Terminal - exited permanently */
35
40
  IDENTITY_STATE_WITHDRAWN = "IDENTITY_STATE_WITHDRAWN",
36
41
  UNRECOGNIZED = "UNRECOGNIZED"
37
42
  }
@@ -59,116 +64,90 @@ export interface PlatformLink {
59
64
  linkedAt?: Date | undefined;
60
65
  verified: boolean;
61
66
  }
62
- /** Reputation metrics (extended for oracles) */
67
+ /** Reputation metrics (unified for all identity types) */
63
68
  export interface Reputation {
64
69
  /** Overall reputation score */
65
70
  score: number;
66
- /** Accuracy for oracles (0-100) */
67
- accuracyPercentage: number;
68
- /** Total interactions/resolutions */
69
- totalInteractions: number;
70
- /** Disputes resolved favorably */
71
+ /** Accuracy percentage (oracles) */
72
+ accuracy: number;
73
+ /** Total actions/resolutions */
74
+ totalActions: number;
71
75
  disputesWon: number;
72
- /** Disputes resolved against */
73
76
  disputesLost: number;
74
77
  }
75
- /** Record of a penalty/slashing event */
78
+ /** Record of a penalty event (slashing, suspension, etc.) */
76
79
  export interface PenaltyEvent {
77
- /** Description of infraction */
78
80
  reason: string;
79
- /** Amount penalized */
81
+ /** Amount slashed (if applicable) */
80
82
  amount: number;
81
83
  /** Market/contract where infraction occurred */
82
84
  contextId: string;
83
- /** When penalty occurred */
84
85
  timestamp?: Date | undefined;
85
86
  }
86
- /** Universal identity container */
87
+ /** Unified identity on-chain state */
87
88
  export interface Identity {
88
- /** Unique identifier */
89
89
  id: string;
90
- /** Type of identity */
91
- identityType: IdentityType;
92
- /** DAG address */
93
90
  address: string;
94
- /** Public key */
95
91
  publicKey: string;
96
- /** Human-readable name */
97
92
  displayName: string;
98
- /** Current state */
93
+ identityType: IdentityType;
99
94
  state: IdentityState;
100
- /** Reputation metrics */
101
95
  reputation?: Reputation | undefined;
102
- /** Social links (agents) */
103
- platformLinks: PlatformLink[];
104
- /** Staked amount (oracles) */
96
+ /** Staked amount (oracles/services) */
105
97
  stake: number;
106
98
  /** Expertise domains (oracles) */
107
99
  domains: string[];
108
- /** Slashing/penalty history */
100
+ platformLinks: PlatformLink[];
109
101
  penaltyHistory: PenaltyEvent[];
110
- /** Creation timestamp */
111
102
  createdAt?: Date | undefined;
112
- /** Last update timestamp */
113
103
  updatedAt?: Date | undefined;
114
104
  }
115
- /** Register a new identity */
116
105
  export interface RegisterIdentityRequest {
117
106
  identityType: IdentityType;
118
107
  address: string;
119
108
  displayName: string;
120
- /** For oracles */
109
+ /** For oracles/services */
121
110
  initialStake: number;
122
111
  /** For oracles */
123
112
  domains: string[];
124
113
  }
125
- /** Activate a registered identity */
126
114
  export interface ActivateIdentityRequest {
127
115
  identityId: string;
128
116
  address: string;
129
117
  }
130
- /** Update identity stake */
131
- export interface UpdateStakeRequest {
118
+ export interface LinkPlatformRequest {
132
119
  identityId: string;
133
- address: string;
134
- /** Positive to add, negative to withdraw */
135
- amount: number;
120
+ platform: Platform;
121
+ platformUserId: string;
122
+ platformUsername: string;
136
123
  }
137
- /** Challenge an identity */
138
124
  export interface ChallengeIdentityRequest {
139
125
  identityId: string;
140
- challenger: string;
126
+ challengerAddress: string;
141
127
  reason: string;
142
- evidence: string;
143
128
  }
144
- /** Penalize/slash an identity */
145
- export interface PenalizeIdentityRequest {
129
+ export interface AddStakeRequest {
146
130
  identityId: string;
147
- /** Market/contract context */
148
- contextId: string;
149
- reason: string;
131
+ address: string;
150
132
  amount: number;
151
133
  }
152
- /** Withdraw identity from service */
153
134
  export interface WithdrawIdentityRequest {
154
135
  identityId: string;
155
136
  address: string;
156
137
  }
157
- /** Identity state machine definition */
158
138
  export interface IdentityDefinition {
139
+ /** Configuration for identity state machine */
159
140
  identityType: IdentityType;
160
141
  /** Default starting reputation */
161
142
  initialReputation: number;
162
- /** Minimum stake to activate (oracles) */
163
- minStake: number;
164
- /** Min rep to activate */
143
+ /** Min rep/stake to activate */
165
144
  activationThreshold: number;
166
- /** How long suspension lasts */
145
+ /** Min stake for oracles/services */
146
+ minStake: number;
167
147
  suspensionDurationEpochs: number;
168
- /** Min accuracy to remain active (oracles) */
148
+ slashCooldownEpochs: number;
149
+ /** Min accuracy for oracles */
169
150
  accuracyThreshold: number;
170
- /** Max dispute rate before auto-penalty */
171
- maxDisputeRate: number;
172
151
  }
173
152
  export declare const PlatformLink: MessageFns<PlatformLink>;
174
153
  export declare const Reputation: MessageFns<Reputation>;
@@ -176,9 +155,9 @@ export declare const PenaltyEvent: MessageFns<PenaltyEvent>;
176
155
  export declare const Identity: MessageFns<Identity>;
177
156
  export declare const RegisterIdentityRequest: MessageFns<RegisterIdentityRequest>;
178
157
  export declare const ActivateIdentityRequest: MessageFns<ActivateIdentityRequest>;
179
- export declare const UpdateStakeRequest: MessageFns<UpdateStakeRequest>;
158
+ export declare const LinkPlatformRequest: MessageFns<LinkPlatformRequest>;
180
159
  export declare const ChallengeIdentityRequest: MessageFns<ChallengeIdentityRequest>;
181
- export declare const PenalizeIdentityRequest: MessageFns<PenalizeIdentityRequest>;
160
+ export declare const AddStakeRequest: MessageFns<AddStakeRequest>;
182
161
  export declare const WithdrawIdentityRequest: MessageFns<WithdrawIdentityRequest>;
183
162
  export declare const IdentityDefinition: MessageFns<IdentityDefinition>;
184
163
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Fiber App Definition Schema
3
+ *
4
+ * TypeScript-first definitions for fiber apps. This is the source of truth —
5
+ * no JSON, no code generation. Import types directly.
6
+ */
7
+ export type SchemaFieldType = 'string' | 'integer' | 'number' | 'boolean' | 'address' | 'uri' | 'timestamp' | 'uuid' | 'hash' | 'object' | 'array';
8
+ export interface SchemaField {
9
+ type?: SchemaFieldType;
10
+ description?: string;
11
+ default?: unknown;
12
+ maxLength?: number;
13
+ minLength?: number;
14
+ minimum?: number;
15
+ maximum?: number;
16
+ enum?: readonly string[];
17
+ pattern?: string;
18
+ format?: string;
19
+ nullable?: boolean;
20
+ immutable?: boolean;
21
+ computed?: boolean;
22
+ indexed?: boolean;
23
+ $ref?: string;
24
+ items?: SchemaField | {
25
+ $ref: string;
26
+ };
27
+ properties?: Record<string, SchemaField>;
28
+ required?: readonly string[];
29
+ additionalProperties?: boolean | SchemaField;
30
+ }
31
+ export interface SchemaDefinition {
32
+ type: 'object';
33
+ description?: string;
34
+ required?: readonly string[];
35
+ properties: Record<string, SchemaField>;
36
+ nullable?: boolean;
37
+ }
38
+ export interface EventSchema {
39
+ description?: string;
40
+ required?: readonly string[];
41
+ properties?: Record<string, SchemaField>;
42
+ }
43
+ export interface StateDefinition {
44
+ id: string;
45
+ isFinal: boolean;
46
+ description?: string;
47
+ metadata?: Record<string, unknown> | null;
48
+ }
49
+ export type JsonLogicRule = Record<string, unknown>;
50
+ export interface EmitSpec {
51
+ event: string;
52
+ to?: string;
53
+ payload?: JsonLogicRule;
54
+ }
55
+ export interface DependencySpec {
56
+ machine: string;
57
+ instanceRef: JsonLogicRule;
58
+ requiredState?: string;
59
+ }
60
+ export interface Transition<TState extends string = string, TEvent extends string = string> {
61
+ from: TState;
62
+ to: TState;
63
+ eventName: TEvent;
64
+ guard?: JsonLogicRule;
65
+ effect?: JsonLogicRule;
66
+ dependencies?: readonly (string | DependencySpec)[];
67
+ emits?: readonly (string | EmitSpec)[];
68
+ }
69
+ export interface FiberAppMetadata {
70
+ name: string;
71
+ app: string;
72
+ type: string;
73
+ version: string;
74
+ description?: string;
75
+ category?: string;
76
+ /** Cross-references to other fiber types (informational) */
77
+ crossReferences?: CrossReferences;
78
+ }
79
+ export interface CrossReferenceSpec {
80
+ machine: string;
81
+ description: string;
82
+ foreignKey?: string;
83
+ }
84
+ export interface CrossReferences {
85
+ [key: string]: string | CrossReferenceSpec;
86
+ }
87
+ export interface FiberAppDefinition<TState extends string = string, TEvent extends string = string> {
88
+ metadata: FiberAppMetadata;
89
+ /** Schema for fiber creation inputs (user-provided) */
90
+ createSchema?: {
91
+ required?: readonly string[];
92
+ properties: Record<string, SchemaField>;
93
+ };
94
+ /** Schema for full fiber state (includes computed fields) */
95
+ stateSchema?: {
96
+ properties: Record<string, SchemaField>;
97
+ };
98
+ /** Schema for each event's payload */
99
+ eventSchemas?: Record<TEvent, EventSchema>;
100
+ /** Reusable type definitions */
101
+ definitions?: Record<string, SchemaDefinition>;
102
+ /** State machine states */
103
+ states: Record<TState, StateDefinition>;
104
+ /** Initial state */
105
+ initialState: TState;
106
+ /** State transitions */
107
+ transitions: readonly Transition<TState, TEvent>[];
108
+ }
109
+ /**
110
+ * Define a fiber app with full type inference.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const agentDef = defineFiberApp({
115
+ * metadata: { name: 'Agent', app: 'identity', type: 'agent', version: '1.0.0' },
116
+ * states: {
117
+ * REGISTERED: { id: 'REGISTERED', isFinal: false },
118
+ * ACTIVE: { id: 'ACTIVE', isFinal: false },
119
+ * },
120
+ * initialState: 'REGISTERED',
121
+ * transitions: [
122
+ * { from: 'REGISTERED', to: 'ACTIVE', eventName: 'activate' },
123
+ * ],
124
+ * });
125
+ * ```
126
+ */
127
+ export declare function defineFiberApp<TState extends string, TEvent extends string, TDef extends FiberAppDefinition<TState, TEvent>>(definition: TDef): TDef;
128
+ /** Extract state names from a fiber app definition */
129
+ export type StateNames<T extends FiberAppDefinition> = keyof T['states'] & string;
130
+ /** Extract event names from a fiber app definition */
131
+ export type EventNames<T extends FiberAppDefinition> = T['transitions'][number]['eventName'];
132
+ /** Get valid transitions from a given state */
133
+ export declare function getTransitionsFrom<T extends FiberAppDefinition>(def: T, state: StateNames<T>): T['transitions'][number][];
134
+ /** Get valid event names from a given state */
135
+ export declare function getEventsFrom<T extends FiberAppDefinition>(def: T, state: StateNames<T>): string[];
136
+ /** Check if a state is final */
137
+ export declare function isFinalState<T extends FiberAppDefinition>(def: T, state: StateNames<T>): boolean;
138
+ /** Convert definition to plain JSON (for serialization) */
139
+ export declare function toJSON<T extends FiberAppDefinition>(def: T): object;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Fiber App Schema
3
+ */
4
+ export * from './fiber-app.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottochain/sdk",
3
- "version": "1.7.0-beta.2",
3
+ "version": "2.1.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",