@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.
- package/dist/cjs/apps/contracts/index.js +1 -1
- package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +272 -0
- package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +284 -0
- package/dist/cjs/apps/contracts/state-machines/contract-universal.js +93 -0
- package/dist/cjs/apps/contracts/state-machines/index.js +177 -1
- package/dist/cjs/apps/corporate/state-machines/corp-board.js +1022 -0
- package/dist/cjs/apps/corporate/state-machines/corp-entity.js +671 -0
- package/dist/cjs/apps/corporate/state-machines/corp-securities.js +998 -0
- package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +1102 -0
- package/dist/cjs/apps/corporate/state-machines/index.js +20 -4440
- package/dist/cjs/apps/governance/index.js +7 -7
- package/dist/cjs/apps/governance/state-machines/dao-multisig.js +467 -0
- package/dist/cjs/apps/governance/state-machines/dao-reputation.js +458 -0
- package/dist/cjs/apps/governance/state-machines/dao-single.js +199 -0
- package/dist/cjs/apps/governance/state-machines/dao-token.js +503 -0
- package/dist/cjs/apps/governance/state-machines/governance-simple.js +482 -0
- package/dist/cjs/apps/governance/state-machines/governance-universal.js +138 -0
- package/dist/cjs/apps/governance/state-machines/index.js +16 -2934
- package/dist/cjs/apps/identity/constants.js +20 -20
- package/dist/cjs/apps/identity/index.js +13 -21
- package/dist/cjs/apps/identity/state-machines/identity-agent.js +256 -0
- package/dist/cjs/apps/identity/state-machines/identity-oracle.js +321 -0
- package/dist/cjs/apps/identity/state-machines/identity-universal.js +106 -0
- package/dist/cjs/apps/identity/state-machines/index.js +15 -784
- package/dist/cjs/apps/markets/index.js +1 -1
- package/dist/cjs/apps/markets/state-machines/index.js +14 -2298
- package/dist/cjs/apps/markets/state-machines/market-auction.js +283 -0
- package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +312 -0
- package/dist/cjs/apps/markets/state-machines/market-group-buy.js +407 -0
- package/dist/cjs/apps/markets/state-machines/market-prediction.js +485 -0
- package/dist/cjs/apps/markets/state-machines/market-universal.js +129 -0
- package/dist/cjs/apps/oracles/index.js +36 -0
- package/dist/cjs/generated/index.js +14 -7
- package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +197 -198
- package/dist/cjs/schema/fiber-app.js +55 -0
- package/dist/cjs/schema/index.js +20 -0
- package/dist/esm/apps/contracts/index.js +3 -3
- package/dist/esm/apps/contracts/state-machines/contract-agreement.js +269 -0
- package/dist/esm/apps/contracts/state-machines/contract-escrow.js +281 -0
- package/dist/esm/apps/contracts/state-machines/contract-universal.js +90 -0
- package/dist/esm/apps/contracts/state-machines/index.js +177 -1
- package/dist/esm/apps/corporate/index.js +3 -3
- package/dist/esm/apps/corporate/state-machines/corp-board.js +1019 -0
- package/dist/esm/apps/corporate/state-machines/corp-entity.js +668 -0
- package/dist/esm/apps/corporate/state-machines/corp-securities.js +995 -0
- package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +1099 -0
- package/dist/esm/apps/corporate/state-machines/index.js +15 -4439
- package/dist/esm/apps/governance/index.js +9 -9
- package/dist/esm/apps/governance/state-machines/dao-multisig.js +464 -0
- package/dist/esm/apps/governance/state-machines/dao-reputation.js +455 -0
- package/dist/esm/apps/governance/state-machines/dao-single.js +196 -0
- package/dist/esm/apps/governance/state-machines/dao-token.js +500 -0
- package/dist/esm/apps/governance/state-machines/governance-simple.js +479 -0
- package/dist/esm/apps/governance/state-machines/governance-universal.js +135 -0
- package/dist/esm/apps/governance/state-machines/index.js +9 -2933
- package/dist/esm/apps/identity/constants.js +21 -21
- package/dist/esm/apps/identity/index.js +13 -22
- package/dist/esm/apps/identity/state-machines/identity-agent.js +253 -0
- package/dist/esm/apps/identity/state-machines/identity-oracle.js +318 -0
- package/dist/esm/apps/identity/state-machines/identity-universal.js +103 -0
- package/dist/esm/apps/identity/state-machines/index.js +11 -783
- package/dist/esm/apps/index.js +5 -5
- package/dist/esm/apps/markets/index.js +3 -3
- package/dist/esm/apps/markets/state-machines/index.js +8 -2297
- package/dist/esm/apps/markets/state-machines/market-auction.js +280 -0
- package/dist/esm/apps/markets/state-machines/market-crowdfund.js +309 -0
- package/dist/esm/apps/markets/state-machines/market-group-buy.js +404 -0
- package/dist/esm/apps/markets/state-machines/market-prediction.js +482 -0
- package/dist/esm/apps/markets/state-machines/market-universal.js +126 -0
- package/dist/esm/apps/oracles/index.js +21 -0
- package/dist/esm/generated/index.js +8 -3
- package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +196 -197
- package/dist/esm/schema/fiber-app.js +47 -0
- package/dist/esm/schema/index.js +4 -0
- package/dist/types/apps/contracts/index.d.ts +151 -2
- package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +462 -0
- package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +511 -0
- package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +147 -0
- package/dist/types/apps/contracts/state-machines/index.d.ts +149 -0
- package/dist/types/apps/corporate/index.d.ts +5263 -3825
- package/dist/types/apps/corporate/state-machines/corp-board.d.ts +1479 -0
- package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +970 -0
- package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +1381 -0
- package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +1631 -0
- package/dist/types/apps/corporate/state-machines/index.d.ts +5245 -3802
- package/dist/types/apps/governance/index.d.ts +875 -37
- package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +644 -0
- package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +610 -0
- package/dist/types/apps/governance/state-machines/dao-single.d.ts +276 -0
- package/dist/types/apps/governance/state-machines/dao-token.d.ts +601 -0
- package/dist/types/apps/governance/state-machines/governance-simple.d.ts +652 -0
- package/dist/types/apps/governance/state-machines/governance-universal.d.ts +181 -0
- package/dist/types/apps/governance/state-machines/index.d.ts +9 -2136
- package/dist/types/apps/identity/constants.d.ts +4 -7
- package/dist/types/apps/identity/index.d.ts +1082 -592
- package/dist/types/apps/identity/state-machines/identity-agent.d.ts +401 -0
- package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +550 -0
- package/dist/types/apps/identity/state-machines/identity-universal.d.ts +151 -0
- package/dist/types/apps/identity/state-machines/index.d.ts +1069 -567
- package/dist/types/apps/index.d.ts +5 -5
- package/dist/types/apps/markets/index.d.ts +535 -7
- package/dist/types/apps/markets/state-machines/index.d.ts +8 -1678
- package/dist/types/apps/markets/state-machines/market-auction.d.ts +392 -0
- package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +443 -0
- package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +539 -0
- package/dist/types/apps/markets/state-machines/market-prediction.d.ts +651 -0
- package/dist/types/apps/markets/state-machines/market-universal.d.ts +191 -0
- package/dist/types/apps/oracles/index.d.ts +18 -0
- package/dist/types/generated/index.d.ts +3 -1
- package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +43 -64
- package/dist/types/schema/fiber-app.d.ts +139 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Identity Constants
|
|
3
3
|
*
|
|
4
|
-
* State machine transitions and configuration constants for
|
|
4
|
+
* State machine transitions and configuration constants for identity types.
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
import { IdentityState
|
|
9
|
-
import { AttestationType } from
|
|
8
|
+
import { IdentityState } from "../../generated/ottochain/apps/identity/v1/identity.js";
|
|
9
|
+
import { AttestationType } from "../../generated/ottochain/apps/identity/v1/attestation.js";
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// State Machine Transitions
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
/**
|
|
14
14
|
* Valid transitions for each identity state.
|
|
15
15
|
* Maps current state to allowed event names.
|
|
16
|
+
* Note: Some transitions are type-specific (agent vs oracle)
|
|
16
17
|
*/
|
|
17
18
|
export const IDENTITY_TRANSITIONS = {
|
|
18
19
|
[IdentityState.IDENTITY_STATE_UNSPECIFIED]: [],
|
|
19
|
-
[IdentityState.IDENTITY_STATE_UNREGISTERED]: [
|
|
20
|
-
[IdentityState.IDENTITY_STATE_REGISTERED]: [
|
|
21
|
-
[IdentityState.IDENTITY_STATE_ACTIVE]: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
[IdentityState.IDENTITY_STATE_UNREGISTERED]: ["register"],
|
|
21
|
+
[IdentityState.IDENTITY_STATE_REGISTERED]: ["activate", "withdraw"],
|
|
22
|
+
[IdentityState.IDENTITY_STATE_ACTIVE]: [
|
|
23
|
+
"challenge",
|
|
24
|
+
"slash",
|
|
25
|
+
"deactivate",
|
|
26
|
+
"withdraw",
|
|
27
|
+
],
|
|
28
|
+
[IdentityState.IDENTITY_STATE_CHALLENGED]: [
|
|
29
|
+
"uphold_challenge",
|
|
30
|
+
"dismiss_challenge",
|
|
31
|
+
],
|
|
32
|
+
[IdentityState.IDENTITY_STATE_SUSPENDED]: ["begin_probation"],
|
|
33
|
+
[IdentityState.IDENTITY_STATE_PROBATION]: ["complete_probation"],
|
|
34
|
+
[IdentityState.IDENTITY_STATE_SLASHED]: ["reactivate", "withdraw"],
|
|
35
|
+
[IdentityState.IDENTITY_STATE_INACTIVE]: ["activate", "withdraw"],
|
|
26
36
|
[IdentityState.IDENTITY_STATE_WITHDRAWN]: [], // Terminal state
|
|
27
37
|
[IdentityState.UNRECOGNIZED]: [],
|
|
28
38
|
};
|
|
29
|
-
// Legacy alias
|
|
39
|
+
// Legacy alias
|
|
30
40
|
export const AGENT_TRANSITIONS = IDENTITY_TRANSITIONS;
|
|
31
41
|
// ---------------------------------------------------------------------------
|
|
32
42
|
// Reputation Configuration
|
|
@@ -55,13 +65,3 @@ export function canTransition(state, event) {
|
|
|
55
65
|
export function getReputationDelta(type) {
|
|
56
66
|
return ATTESTATION_DELTAS[type] ?? 0;
|
|
57
67
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Identity type display names
|
|
60
|
-
*/
|
|
61
|
-
export const IDENTITY_TYPE_NAMES = {
|
|
62
|
-
[IdentityType.IDENTITY_TYPE_UNSPECIFIED]: 'Unknown',
|
|
63
|
-
[IdentityType.IDENTITY_TYPE_AGENT]: 'Agent',
|
|
64
|
-
[IdentityType.IDENTITY_TYPE_ORACLE]: 'Oracle',
|
|
65
|
-
[IdentityType.IDENTITY_TYPE_SERVICE]: 'Service',
|
|
66
|
-
[IdentityType.UNRECOGNIZED]: 'Unknown',
|
|
67
|
-
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Identity Application
|
|
2
|
+
* Agent Identity Application
|
|
3
3
|
*
|
|
4
|
-
* Types and utilities for the Identity system on OttoChain.
|
|
5
|
-
* Includes agents, oracles, and services.
|
|
4
|
+
* Types and utilities for the Agent Identity system on OttoChain.
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
8
7
|
* ```typescript
|
|
9
8
|
* import {
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* AgentState,
|
|
10
|
+
* AgentIdentity,
|
|
12
11
|
* getIdentityDefinition
|
|
13
12
|
* } from '@ottochain/sdk/apps/identity';
|
|
14
13
|
*
|
|
15
|
-
* const
|
|
14
|
+
* const identityDef = getIdentityDefinition();
|
|
16
15
|
* ```
|
|
17
16
|
*
|
|
18
17
|
* @packageDocumentation
|
|
19
18
|
*/
|
|
20
19
|
// Re-export generated protobuf types (source of truth)
|
|
21
|
-
export { IdentityType, IdentityState, Platform, PlatformLink, Reputation, PenaltyEvent, Identity, RegisterIdentityRequest, ActivateIdentityRequest,
|
|
22
|
-
|
|
20
|
+
export { IdentityType, IdentityState, Platform, PlatformLink, Reputation, PenaltyEvent, Identity, RegisterIdentityRequest, ActivateIdentityRequest, LinkPlatformRequest, ChallengeIdentityRequest, AddStakeRequest, WithdrawIdentityRequest, IdentityDefinition, identityTypeFromJSON, identityTypeToJSON, identityStateFromJSON, identityStateToJSON, platformFromJSON, platformToJSON, } from "../../generated/ottochain/apps/identity/v1/identity.js";
|
|
21
|
+
// Legacy aliases for backward compatibility
|
|
22
|
+
export { IdentityState as AgentState } from "../../generated/ottochain/apps/identity/v1/identity.js";
|
|
23
|
+
export { AttestationType, ReputationDelta, Attestation, VouchRequest, ChallengeRequest, ReputationConfig, attestationTypeFromJSON, attestationTypeToJSON, } from "../../generated/ottochain/apps/identity/v1/attestation.js";
|
|
23
24
|
// Re-export constants and utilities
|
|
24
|
-
export { IDENTITY_TRANSITIONS, AGENT_TRANSITIONS,
|
|
25
|
-
ATTESTATION_DELTAS, IDENTITY_TYPE_NAMES, canTransition, getReputationDelta, } from './constants.js';
|
|
25
|
+
export { IDENTITY_TRANSITIONS, AGENT_TRANSITIONS, ATTESTATION_DELTAS, canTransition, getReputationDelta, } from "./constants.js";
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
27
27
|
// Configuration Defaults
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
/**
|
|
30
|
-
* Default reputation configuration for
|
|
30
|
+
* Default reputation configuration for agent identity
|
|
31
31
|
*/
|
|
32
32
|
export const DEFAULT_REPUTATION_CONFIG = {
|
|
33
33
|
baseReputation: 10,
|
|
@@ -38,19 +38,10 @@ export const DEFAULT_REPUTATION_CONFIG = {
|
|
|
38
38
|
minReputation: 0,
|
|
39
39
|
challengeThreshold: 5,
|
|
40
40
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Default oracle configuration
|
|
43
|
-
*/
|
|
44
|
-
export const DEFAULT_ORACLE_CONFIG = {
|
|
45
|
-
minStake: 100,
|
|
46
|
-
slashCooldownEpochs: 7,
|
|
47
|
-
accuracyThreshold: 70,
|
|
48
|
-
maxDisputeRate: 30,
|
|
49
|
-
};
|
|
50
41
|
// ---------------------------------------------------------------------------
|
|
51
42
|
// State Machine Definitions (generated from JSON at build time)
|
|
52
43
|
// ---------------------------------------------------------------------------
|
|
53
|
-
import { identityUniversalDef, identityAgentDef, identityOracleDef, } from
|
|
44
|
+
import { identityUniversalDef, identityAgentDef, identityOracleDef, } from "./state-machines/index.js";
|
|
54
45
|
export { identityUniversalDef, identityAgentDef, identityOracleDef };
|
|
55
46
|
/** All identity state machine definitions */
|
|
56
47
|
export const IDENTITY_DEFINITIONS = {
|
|
@@ -62,6 +53,6 @@ export const IDENTITY_DEFINITIONS = {
|
|
|
62
53
|
* Get an identity state machine definition by type.
|
|
63
54
|
* @param type - 'universal' | 'agent' | 'oracle' (default: 'agent')
|
|
64
55
|
*/
|
|
65
|
-
export function getIdentityDefinition(type =
|
|
56
|
+
export function getIdentityDefinition(type = "agent") {
|
|
66
57
|
return IDENTITY_DEFINITIONS[type];
|
|
67
58
|
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { defineFiberApp } from "../../../schema/fiber-app.js";
|
|
2
|
+
/**
|
|
3
|
+
* Standard agent identity with reputation tracking, vouching, and lifecycle management.
|
|
4
|
+
*/
|
|
5
|
+
export const identityAgentDef = defineFiberApp({
|
|
6
|
+
metadata: {
|
|
7
|
+
name: "IdentityAgent",
|
|
8
|
+
app: "identity",
|
|
9
|
+
type: "agent",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
description: "Standard agent identity with reputation tracking, vouching, and lifecycle management",
|
|
12
|
+
},
|
|
13
|
+
createSchema: {
|
|
14
|
+
required: ["owner", "displayName"],
|
|
15
|
+
properties: {
|
|
16
|
+
owner: {
|
|
17
|
+
type: "address",
|
|
18
|
+
description: "Agent owner DAG address",
|
|
19
|
+
immutable: true,
|
|
20
|
+
},
|
|
21
|
+
displayName: {
|
|
22
|
+
type: "string",
|
|
23
|
+
maxLength: 64,
|
|
24
|
+
description: "Human-readable agent name",
|
|
25
|
+
},
|
|
26
|
+
bio: {
|
|
27
|
+
type: "string",
|
|
28
|
+
maxLength: 256,
|
|
29
|
+
default: "",
|
|
30
|
+
},
|
|
31
|
+
avatar: {
|
|
32
|
+
type: "uri",
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
platforms: {
|
|
36
|
+
type: "array",
|
|
37
|
+
items: { $ref: "#/definitions/PlatformLink" },
|
|
38
|
+
default: [],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
stateSchema: {
|
|
43
|
+
properties: {
|
|
44
|
+
owner: { type: "address", immutable: true },
|
|
45
|
+
displayName: { type: "string" },
|
|
46
|
+
bio: { type: "string" },
|
|
47
|
+
avatar: { type: "uri" },
|
|
48
|
+
platforms: {
|
|
49
|
+
type: "array",
|
|
50
|
+
items: { $ref: "#/definitions/PlatformLink" },
|
|
51
|
+
},
|
|
52
|
+
status: {
|
|
53
|
+
type: "string",
|
|
54
|
+
enum: [
|
|
55
|
+
"REGISTERED",
|
|
56
|
+
"ACTIVE",
|
|
57
|
+
"CHALLENGED",
|
|
58
|
+
"SUSPENDED",
|
|
59
|
+
"PROBATION",
|
|
60
|
+
"WITHDRAWN",
|
|
61
|
+
],
|
|
62
|
+
computed: true,
|
|
63
|
+
},
|
|
64
|
+
reputation: { type: "integer", default: 10, computed: true },
|
|
65
|
+
activatedAt: { type: "timestamp", computed: true },
|
|
66
|
+
suspendedAt: { type: "timestamp", computed: true },
|
|
67
|
+
probationStartedAt: { type: "timestamp", computed: true },
|
|
68
|
+
challengedBy: { type: "address", computed: true },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
eventSchemas: {
|
|
72
|
+
activate: {
|
|
73
|
+
description: "Activate a registered agent",
|
|
74
|
+
},
|
|
75
|
+
receive_vouch: {
|
|
76
|
+
description: "Receive a vouch from another agent",
|
|
77
|
+
required: ["from"],
|
|
78
|
+
properties: {
|
|
79
|
+
from: { type: "address", description: "Address of vouching agent" },
|
|
80
|
+
weight: { type: "integer", minimum: 1, maximum: 10, default: 1 },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
receive_completion: {
|
|
84
|
+
description: "Receive completion attestation from a fiber",
|
|
85
|
+
},
|
|
86
|
+
challenge: {
|
|
87
|
+
description: "Challenge an active agent's behavior",
|
|
88
|
+
required: ["challenger", "reason"],
|
|
89
|
+
properties: {
|
|
90
|
+
challenger: { type: "address" },
|
|
91
|
+
reason: { type: "string", maxLength: 512 },
|
|
92
|
+
evidence: { type: "array", items: { type: "uri" } },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
dismiss_challenge: {
|
|
96
|
+
description: "Dismiss an active challenge",
|
|
97
|
+
},
|
|
98
|
+
uphold_challenge: {
|
|
99
|
+
description: "Uphold a challenge, suspending the agent",
|
|
100
|
+
},
|
|
101
|
+
begin_probation: {
|
|
102
|
+
description: "Move suspended agent to probation",
|
|
103
|
+
},
|
|
104
|
+
complete_probation: {
|
|
105
|
+
description: "Complete probation, reactivating the agent",
|
|
106
|
+
},
|
|
107
|
+
withdraw: {
|
|
108
|
+
description: "Permanently withdraw the agent",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
definitions: {
|
|
112
|
+
PlatformLink: {
|
|
113
|
+
type: "object",
|
|
114
|
+
required: ["platform", "handle"],
|
|
115
|
+
properties: {
|
|
116
|
+
platform: {
|
|
117
|
+
type: "string",
|
|
118
|
+
enum: [
|
|
119
|
+
"twitter",
|
|
120
|
+
"github",
|
|
121
|
+
"discord",
|
|
122
|
+
"telegram",
|
|
123
|
+
"moltbook",
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
handle: { type: "string" },
|
|
127
|
+
verified: { type: "boolean", default: false },
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
states: {
|
|
132
|
+
REGISTERED: { id: "REGISTERED", isFinal: false },
|
|
133
|
+
ACTIVE: { id: "ACTIVE", isFinal: false },
|
|
134
|
+
CHALLENGED: { id: "CHALLENGED", isFinal: false },
|
|
135
|
+
SUSPENDED: { id: "SUSPENDED", isFinal: false },
|
|
136
|
+
PROBATION: { id: "PROBATION", isFinal: false },
|
|
137
|
+
WITHDRAWN: { id: "WITHDRAWN", isFinal: true },
|
|
138
|
+
},
|
|
139
|
+
initialState: "REGISTERED",
|
|
140
|
+
transitions: [
|
|
141
|
+
{
|
|
142
|
+
from: "REGISTERED",
|
|
143
|
+
to: "ACTIVE",
|
|
144
|
+
eventName: "activate",
|
|
145
|
+
guard: { "==": [1, 1] },
|
|
146
|
+
effect: {
|
|
147
|
+
merge: [
|
|
148
|
+
{ var: "state" },
|
|
149
|
+
{ status: "ACTIVE", activatedAt: { var: "$timestamp" } },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
from: "ACTIVE",
|
|
155
|
+
to: "ACTIVE",
|
|
156
|
+
eventName: "receive_vouch",
|
|
157
|
+
guard: { "!!": [{ var: "event.from" }] },
|
|
158
|
+
effect: {
|
|
159
|
+
merge: [
|
|
160
|
+
{ var: "state" },
|
|
161
|
+
{ reputation: { "+": [{ var: "state.reputation" }, 2] } },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
from: "ACTIVE",
|
|
167
|
+
to: "ACTIVE",
|
|
168
|
+
eventName: "receive_completion",
|
|
169
|
+
guard: { "==": [1, 1] },
|
|
170
|
+
effect: {
|
|
171
|
+
merge: [
|
|
172
|
+
{ var: "state" },
|
|
173
|
+
{ reputation: { "+": [{ var: "state.reputation" }, 5] } },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
from: "ACTIVE",
|
|
179
|
+
to: "CHALLENGED",
|
|
180
|
+
eventName: "challenge",
|
|
181
|
+
guard: { "!!": [{ var: "event.challenger" }] },
|
|
182
|
+
effect: {
|
|
183
|
+
merge: [
|
|
184
|
+
{ var: "state" },
|
|
185
|
+
{ status: "CHALLENGED", challengedBy: { var: "event.challenger" } },
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
from: "CHALLENGED",
|
|
191
|
+
to: "ACTIVE",
|
|
192
|
+
eventName: "dismiss_challenge",
|
|
193
|
+
guard: { "==": [1, 1] },
|
|
194
|
+
effect: {
|
|
195
|
+
merge: [{ var: "state" }, { status: "ACTIVE", challengedBy: null }],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
from: "CHALLENGED",
|
|
200
|
+
to: "SUSPENDED",
|
|
201
|
+
eventName: "uphold_challenge",
|
|
202
|
+
guard: { "==": [1, 1] },
|
|
203
|
+
effect: {
|
|
204
|
+
merge: [
|
|
205
|
+
{ var: "state" },
|
|
206
|
+
{ status: "SUSPENDED", suspendedAt: { var: "$timestamp" } },
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
from: "SUSPENDED",
|
|
212
|
+
to: "PROBATION",
|
|
213
|
+
eventName: "begin_probation",
|
|
214
|
+
guard: { "==": [1, 1] },
|
|
215
|
+
effect: {
|
|
216
|
+
merge: [
|
|
217
|
+
{ var: "state" },
|
|
218
|
+
{ status: "PROBATION", probationStartedAt: { var: "$timestamp" } },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
from: "PROBATION",
|
|
224
|
+
to: "ACTIVE",
|
|
225
|
+
eventName: "complete_probation",
|
|
226
|
+
guard: { "==": [1, 1] },
|
|
227
|
+
effect: {
|
|
228
|
+
merge: [
|
|
229
|
+
{ var: "state" },
|
|
230
|
+
{ status: "ACTIVE", probationStartedAt: null },
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
from: "ACTIVE",
|
|
236
|
+
to: "WITHDRAWN",
|
|
237
|
+
eventName: "withdraw",
|
|
238
|
+
guard: { "==": [1, 1] },
|
|
239
|
+
effect: {
|
|
240
|
+
merge: [{ var: "state" }, { status: "WITHDRAWN" }],
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
from: "REGISTERED",
|
|
245
|
+
to: "WITHDRAWN",
|
|
246
|
+
eventName: "withdraw",
|
|
247
|
+
guard: { "==": [1, 1] },
|
|
248
|
+
effect: {
|
|
249
|
+
merge: [{ var: "state" }, { status: "WITHDRAWN" }],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
});
|