@wowok/agent-mcp 2.4.3 → 2.5.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.
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1412 -6
- package/dist/schema/project/index.js +441 -3
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1809 -336
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +578 -579
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +0 -514
- package/dist/schemas/onchain_operations_permission.schema.json +0 -514
- package/dist/schemas/onchain_operations_personal.schema.json +0 -514
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +918 -0
- package/dist/schemas/project_operation.schema.json +474 -3
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +262 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +96 -25
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type RewardRiskAssessment } from "./reward-risk.js";
|
|
2
|
+
export type RewardConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
|
|
3
|
+
export interface RewardConfirmGateResult {
|
|
4
|
+
status: RewardConfirmGateStatus;
|
|
5
|
+
checklist_result: RewardChecklistResult;
|
|
6
|
+
risk_result?: RewardRiskAssessment;
|
|
7
|
+
user_confirmation?: RewardUserConfirmation;
|
|
8
|
+
environment_result?: RewardEnvironmentResult;
|
|
9
|
+
confirmation_text?: string;
|
|
10
|
+
block_reason?: string;
|
|
11
|
+
decision_record: RewardDecisionRecord;
|
|
12
|
+
}
|
|
13
|
+
export interface RewardChecklistResult {
|
|
14
|
+
all_passed: boolean;
|
|
15
|
+
items: RewardChecklistItem[];
|
|
16
|
+
}
|
|
17
|
+
export interface RewardChecklistItem {
|
|
18
|
+
id: string;
|
|
19
|
+
description: string;
|
|
20
|
+
passed: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RewardUserConfirmation {
|
|
24
|
+
questions_asked: RewardConfirmationQuestion[];
|
|
25
|
+
responses: RewardConfirmationResponse[];
|
|
26
|
+
all_confirmed: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface RewardConfirmationQuestion {
|
|
29
|
+
id: string;
|
|
30
|
+
question: string;
|
|
31
|
+
requires_explicit_yes: boolean;
|
|
32
|
+
related_risk_ids?: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface RewardConfirmationResponse {
|
|
35
|
+
question_id: string;
|
|
36
|
+
response: "yes" | "no" | "skip";
|
|
37
|
+
}
|
|
38
|
+
export interface RewardEnvironmentResult {
|
|
39
|
+
passed: boolean;
|
|
40
|
+
checks: {
|
|
41
|
+
name: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface RewardDecisionRecord {
|
|
47
|
+
timestamp: string;
|
|
48
|
+
gate_version: string;
|
|
49
|
+
final_status: RewardConfirmGateStatus;
|
|
50
|
+
layers_passed: string[];
|
|
51
|
+
layers_failed: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface RewardJsonForConfirm {
|
|
54
|
+
object?: string | null;
|
|
55
|
+
claim?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
coin_add?: {
|
|
58
|
+
amount: string | number;
|
|
59
|
+
coin_type: string;
|
|
60
|
+
};
|
|
61
|
+
receive?: {
|
|
62
|
+
token_type: string;
|
|
63
|
+
};
|
|
64
|
+
guard_add?: Array<{
|
|
65
|
+
guard: string;
|
|
66
|
+
recipient: {
|
|
67
|
+
GuardIdentifier: number;
|
|
68
|
+
} | {
|
|
69
|
+
Entity: string;
|
|
70
|
+
} | {
|
|
71
|
+
Signer: unknown;
|
|
72
|
+
};
|
|
73
|
+
amount: {
|
|
74
|
+
type: string;
|
|
75
|
+
value: number | string;
|
|
76
|
+
};
|
|
77
|
+
expiration_time?: number;
|
|
78
|
+
store_from_id?: number | null;
|
|
79
|
+
}>;
|
|
80
|
+
guard_remove_expired?: boolean;
|
|
81
|
+
guard_expiration_time?: number | null;
|
|
82
|
+
owner_receive?: unknown;
|
|
83
|
+
um?: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface RewardConfirmGateInput {
|
|
86
|
+
reward_json: RewardJsonForConfirm;
|
|
87
|
+
intent?: string;
|
|
88
|
+
reward_type?: string;
|
|
89
|
+
current_balance?: string;
|
|
90
|
+
current_guard_count?: number;
|
|
91
|
+
current_record_count_for_recipient?: number;
|
|
92
|
+
current_guard_not_added_expiration_time?: number | null;
|
|
93
|
+
current_clock_ms?: number;
|
|
94
|
+
permission_address?: string;
|
|
95
|
+
signer?: string;
|
|
96
|
+
target_guard_addresses?: string[];
|
|
97
|
+
passport_submission_value_types?: Record<number, string>;
|
|
98
|
+
passport_identifier_is_address?: Record<number, boolean>;
|
|
99
|
+
guard_store_from_id_compatible?: Record<string, boolean>;
|
|
100
|
+
skip_user_confirmation?: boolean;
|
|
101
|
+
skip_environment_check?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export declare const REWARD_OPERATION_CHECKLIST: RewardChecklistItem[];
|
|
104
|
+
export declare const REWARD_CONFIRMATION_QUESTIONS: RewardConfirmationQuestion[];
|
|
105
|
+
export declare const REWARD_CONFIRM_VERSION = "1.0.0";
|
|
106
|
+
export declare function runRewardConfirmGate(input: RewardConfirmGateInput): RewardConfirmGateResult;
|
|
107
|
+
export interface ProgressiveRewardCheckResult {
|
|
108
|
+
stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
|
|
109
|
+
status: "pass" | "fail" | "pending";
|
|
110
|
+
message: string;
|
|
111
|
+
next_action?: string;
|
|
112
|
+
}
|
|
113
|
+
export declare function progressiveRewardCheck(input: RewardConfirmGateInput): ProgressiveRewardCheckResult;
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, } from "./onchain-constants.js";
|
|
2
|
+
import { assessRewardRisks, } from "./reward-risk.js";
|
|
3
|
+
export const REWARD_OPERATION_CHECKLIST = [
|
|
4
|
+
{ id: "C-R-01", description: "guard_add count < MAX_GUARD_COUNT_REWARD (200)", passed: false, message: "" },
|
|
5
|
+
{ id: "C-R-02", description: "Per-recipient record count < MAX_RECORD_COUNT_REWARD (5200)", passed: false, message: "" },
|
|
6
|
+
{ id: "C-R-03", description: "claim: balance ≥ amount (E_INSUFFICIENT_BALANCE)", passed: false, message: "" },
|
|
7
|
+
{ id: "C-R-04", description: "guard_add: clock > guard_not_added_expiration_time (if Some)", passed: false, message: "" },
|
|
8
|
+
{ id: "C-R-05", description: "guard_add / claim: clock ≤ guard.expiration_time (if Some)", passed: false, message: "" },
|
|
9
|
+
{ id: "C-R-06", description: "guard_add: valid Recipient × Amount pairing (6 constructors)", passed: false, message: "" },
|
|
10
|
+
{ id: "C-R-07", description: "coin_add: coin type T matches Reward<T>", passed: false, message: "" },
|
|
11
|
+
{ id: "C-R-08", description: "claim: Passport is provided (SDK W_ERROR if missing)", passed: false, message: "" },
|
|
12
|
+
{ id: "C-R-09", description: "owner_receive (156): user double-confirms blast radius", passed: false, message: "" },
|
|
13
|
+
{ id: "C-R-10", description: "guard_expiration_time_add (155): new time > current clock", passed: false, message: "" },
|
|
14
|
+
];
|
|
15
|
+
function runStaticChecklist(input) {
|
|
16
|
+
const items = REWARD_OPERATION_CHECKLIST.map(c => ({ ...c }));
|
|
17
|
+
const data = input.reward_json;
|
|
18
|
+
const cr01 = items.find(i => i.id === "C-R-01");
|
|
19
|
+
if (data.guard_add && data.guard_add.length > 0) {
|
|
20
|
+
const current = input.current_guard_count ?? 0;
|
|
21
|
+
if (current + data.guard_add.length > MAX_GUARD_COUNT_REWARD) {
|
|
22
|
+
cr01.passed = false;
|
|
23
|
+
cr01.message = `${current + data.guard_add.length} > ${MAX_GUARD_COUNT_REWARD}`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
cr01.passed = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
cr01.passed = true;
|
|
31
|
+
}
|
|
32
|
+
const cr02 = items.find(i => i.id === "C-R-02");
|
|
33
|
+
if (data.claim) {
|
|
34
|
+
const records = input.current_record_count_for_recipient ?? 0;
|
|
35
|
+
if (records >= MAX_RECORD_COUNT_REWARD) {
|
|
36
|
+
cr02.passed = false;
|
|
37
|
+
cr02.message = `${records} ≥ ${MAX_RECORD_COUNT_REWARD}`;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
cr02.passed = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
cr02.passed = true;
|
|
45
|
+
}
|
|
46
|
+
const cr03 = items.find(i => i.id === "C-R-03");
|
|
47
|
+
if (data.claim && input.current_balance !== undefined) {
|
|
48
|
+
const balance = BigInt(input.current_balance);
|
|
49
|
+
if (balance === 0n) {
|
|
50
|
+
cr03.passed = false;
|
|
51
|
+
cr03.message = `balance=0 — claim will abort E_INSUFFICIENT_BALANCE`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
cr03.passed = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
cr03.passed = true;
|
|
59
|
+
}
|
|
60
|
+
const cr04 = items.find(i => i.id === "C-R-04");
|
|
61
|
+
if (data.guard_add && data.guard_add.length > 0 && input.current_guard_not_added_expiration_time != null) {
|
|
62
|
+
const clock = input.current_clock_ms ?? Date.now();
|
|
63
|
+
if (clock <= input.current_guard_not_added_expiration_time) {
|
|
64
|
+
cr04.passed = false;
|
|
65
|
+
cr04.message = `clock ${clock} ≤ lock ${input.current_guard_not_added_expiration_time}`;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
cr04.passed = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
cr04.passed = true;
|
|
73
|
+
}
|
|
74
|
+
const cr05 = items.find(i => i.id === "C-R-05");
|
|
75
|
+
cr05.passed = true;
|
|
76
|
+
const cr06 = items.find(i => i.id === "C-R-06");
|
|
77
|
+
if (data.guard_add) {
|
|
78
|
+
const validRecipientKeys = ["GuardIdentifier", "Entity", "Signer"];
|
|
79
|
+
const validAmountTypes = ["Fixed", "GuardU64Identifier", "GUARDU64IDENTIFIER", "GUARD_U64_IDENTIFIER"];
|
|
80
|
+
let allValid = true;
|
|
81
|
+
for (const g of data.guard_add) {
|
|
82
|
+
const rKeys = Object.keys(g.recipient);
|
|
83
|
+
if (rKeys.length !== 1 || !validRecipientKeys.includes(rKeys[0])) {
|
|
84
|
+
allValid = false;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (!validAmountTypes.includes(String(g.amount.type).toUpperCase())) {
|
|
88
|
+
allValid = false;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
cr06.passed = allValid;
|
|
93
|
+
cr06.message = allValid ? "" : "Invalid Recipient × Amount pairing";
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
cr06.passed = true;
|
|
97
|
+
}
|
|
98
|
+
const cr07 = items.find(i => i.id === "C-R-07");
|
|
99
|
+
if (data.coin_add && input.reward_type) {
|
|
100
|
+
cr07.passed = data.coin_add.coin_type === input.reward_type;
|
|
101
|
+
cr07.message = cr07.passed ? "" : `${data.coin_add.coin_type} ≠ ${input.reward_type}`;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
cr07.passed = true;
|
|
105
|
+
}
|
|
106
|
+
const cr08 = items.find(i => i.id === "C-R-08");
|
|
107
|
+
if (data.claim) {
|
|
108
|
+
cr08.passed = true;
|
|
109
|
+
cr08.message = "Passport presence verified by SDK operate()";
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
cr08.passed = true;
|
|
113
|
+
}
|
|
114
|
+
const cr09 = items.find(i => i.id === "C-R-09");
|
|
115
|
+
if (data.owner_receive != null) {
|
|
116
|
+
cr09.passed = false;
|
|
117
|
+
cr09.message = "Pending user confirmation in L3 (QRW3)";
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
cr09.passed = true;
|
|
121
|
+
}
|
|
122
|
+
const cr10 = items.find(i => i.id === "C-R-10");
|
|
123
|
+
if (data.guard_expiration_time !== undefined && data.guard_expiration_time !== null) {
|
|
124
|
+
const clock = input.current_clock_ms ?? Date.now();
|
|
125
|
+
if (data.guard_expiration_time <= clock) {
|
|
126
|
+
cr10.passed = false;
|
|
127
|
+
cr10.message = `${data.guard_expiration_time} ≤ clock ${clock}`;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
cr10.passed = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
cr10.passed = true;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
all_passed: items.filter(i => i.id !== "C-R-09").every(i => i.passed),
|
|
138
|
+
items,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function adaptRiskAssessment(input) {
|
|
142
|
+
const ctx = {
|
|
143
|
+
object: input.reward_json.object,
|
|
144
|
+
claim: input.reward_json.claim,
|
|
145
|
+
description: input.reward_json.description,
|
|
146
|
+
coin_add: input.reward_json.coin_add,
|
|
147
|
+
receive: input.reward_json.receive,
|
|
148
|
+
guard_add: input.reward_json.guard_add,
|
|
149
|
+
guard_remove_expired: input.reward_json.guard_remove_expired,
|
|
150
|
+
guard_expiration_time: input.reward_json.guard_expiration_time,
|
|
151
|
+
owner_receive: input.reward_json.owner_receive,
|
|
152
|
+
um: input.reward_json.um,
|
|
153
|
+
reward_type: input.reward_type,
|
|
154
|
+
current_balance: input.current_balance,
|
|
155
|
+
current_guard_count: input.current_guard_count,
|
|
156
|
+
current_record_count_for_recipient: input.current_record_count_for_recipient,
|
|
157
|
+
current_guard_not_added_expiration_time: input.current_guard_not_added_expiration_time,
|
|
158
|
+
current_clock_ms: input.current_clock_ms,
|
|
159
|
+
permission_address: input.permission_address,
|
|
160
|
+
signer: input.signer,
|
|
161
|
+
target_guard_addresses: input.target_guard_addresses,
|
|
162
|
+
passport_submission_value_types: input.passport_submission_value_types,
|
|
163
|
+
passport_identifier_is_address: input.passport_identifier_is_address,
|
|
164
|
+
guard_store_from_id_compatible: input.guard_store_from_id_compatible,
|
|
165
|
+
};
|
|
166
|
+
return assessRewardRisks(ctx);
|
|
167
|
+
}
|
|
168
|
+
export const REWARD_CONFIRMATION_QUESTIONS = [
|
|
169
|
+
{
|
|
170
|
+
id: "QRW1",
|
|
171
|
+
question: "Is the target Reward object address correct, and does its coin type T match the intended token?",
|
|
172
|
+
requires_explicit_yes: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "QRW2",
|
|
176
|
+
question: "For guard_add: is the Guard address valid and added to this Reward (E_GUARD_NOT_FOUND on claim if not)?",
|
|
177
|
+
requires_explicit_yes: true,
|
|
178
|
+
related_risk_ids: ["R-R-5-01"],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "QRW3",
|
|
182
|
+
question: "⚠️ For owner_receive (156): do you confirm sweeping receivables to the Permission owner? Grant 156 only to dedicated addresses.",
|
|
183
|
+
requires_explicit_yes: true,
|
|
184
|
+
related_risk_ids: ["R-R-3-02"],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: "QRW4",
|
|
188
|
+
question: "For guard_expiration_time_add (155): do you acknowledge this sets a time-lock on guard additions (cannot be shortened below current clock)?",
|
|
189
|
+
requires_explicit_yes: true,
|
|
190
|
+
related_risk_ids: ["R-R-3-03", "R-R-4-04"],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "QRW5",
|
|
194
|
+
question: "For claim: is the Passport provided with valid submissions for the Guard (recipient + amount + store_from_id if set)?",
|
|
195
|
+
requires_explicit_yes: true,
|
|
196
|
+
related_risk_ids: ["R-R-2-01", "R-R-2-02", "R-R-2-03"],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "QRW6",
|
|
200
|
+
question: "For coin_add: have you verified the coin type T matches Reward<T> (type mismatch will abort in SDK operate)?",
|
|
201
|
+
requires_explicit_yes: false,
|
|
202
|
+
related_risk_ids: ["R-R-5-02"],
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
function processUserConfirmation(input, assessment) {
|
|
206
|
+
const questions = [...REWARD_CONFIRMATION_QUESTIONS];
|
|
207
|
+
const data = input.reward_json;
|
|
208
|
+
const filtered = [];
|
|
209
|
+
for (const q of questions) {
|
|
210
|
+
if (q.id === "QRW2" && !data.guard_add)
|
|
211
|
+
continue;
|
|
212
|
+
if (q.id === "QRW3" && data.owner_receive == null)
|
|
213
|
+
continue;
|
|
214
|
+
if (q.id === "QRW4" && data.guard_expiration_time === undefined)
|
|
215
|
+
continue;
|
|
216
|
+
if (q.id === "QRW5" && !data.claim)
|
|
217
|
+
continue;
|
|
218
|
+
if (q.id === "QRW6" && !data.coin_add)
|
|
219
|
+
continue;
|
|
220
|
+
filtered.push(q);
|
|
221
|
+
}
|
|
222
|
+
if (input.skip_user_confirmation) {
|
|
223
|
+
return {
|
|
224
|
+
questions_asked: filtered,
|
|
225
|
+
responses: filtered.map(q => ({ question_id: q.id, response: "yes" })),
|
|
226
|
+
all_confirmed: true,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
questions_asked: filtered,
|
|
231
|
+
responses: [],
|
|
232
|
+
all_confirmed: false,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function verifyEnvironment(input) {
|
|
236
|
+
const checks = [];
|
|
237
|
+
if (input.reward_json.object) {
|
|
238
|
+
checks.push({
|
|
239
|
+
name: "reward_exists",
|
|
240
|
+
passed: true,
|
|
241
|
+
message: `Reward ${input.reward_json.object} assumed to exist`,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if (input.permission_address) {
|
|
245
|
+
checks.push({
|
|
246
|
+
name: "permission_exists",
|
|
247
|
+
passed: true,
|
|
248
|
+
message: `Permission ${input.permission_address} assumed to exist`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
if (input.reward_json.claim && input.target_guard_addresses) {
|
|
252
|
+
const isBound = input.target_guard_addresses.includes(input.reward_json.claim);
|
|
253
|
+
checks.push({
|
|
254
|
+
name: "guard_bound_to_reward",
|
|
255
|
+
passed: isBound,
|
|
256
|
+
message: isBound
|
|
257
|
+
? `Guard ${input.reward_json.claim} is in Reward.guards`
|
|
258
|
+
: `Guard ${input.reward_json.claim} NOT in Reward.guards — E_GUARD_NOT_FOUND will abort`,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (input.reward_json.claim && input.current_balance !== undefined) {
|
|
262
|
+
const balance = BigInt(input.current_balance);
|
|
263
|
+
checks.push({
|
|
264
|
+
name: "balance_positive_for_claim",
|
|
265
|
+
passed: balance > 0n,
|
|
266
|
+
message: balance > 0n
|
|
267
|
+
? `Balance ${input.current_balance} > 0`
|
|
268
|
+
: `Balance is 0 — E_INSUFFICIENT_BALANCE will abort`,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (input.signer && input.permission_address) {
|
|
272
|
+
checks.push({
|
|
273
|
+
name: "signer_authorization",
|
|
274
|
+
passed: true,
|
|
275
|
+
message: `Signer ${input.signer} assumed authorized (verify via queryObjectPermission)`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const allPassed = checks.every(c => c.passed);
|
|
279
|
+
return { passed: allPassed, checks };
|
|
280
|
+
}
|
|
281
|
+
export const REWARD_CONFIRM_VERSION = "1.0.0";
|
|
282
|
+
export function runRewardConfirmGate(input) {
|
|
283
|
+
const layersPassed = [];
|
|
284
|
+
const layersFailed = [];
|
|
285
|
+
const checklist = runStaticChecklist(input);
|
|
286
|
+
if (!checklist.all_passed) {
|
|
287
|
+
layersFailed.push("L1_checklist");
|
|
288
|
+
return {
|
|
289
|
+
status: "blocked_checklist",
|
|
290
|
+
checklist_result: checklist,
|
|
291
|
+
confirmation_text: generateConfirmationText(input, checklist),
|
|
292
|
+
block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
293
|
+
decision_record: {
|
|
294
|
+
timestamp: new Date().toISOString(),
|
|
295
|
+
gate_version: REWARD_CONFIRM_VERSION,
|
|
296
|
+
final_status: "blocked_checklist",
|
|
297
|
+
layers_passed: layersPassed,
|
|
298
|
+
layers_failed: layersFailed,
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
layersPassed.push("L1_checklist");
|
|
303
|
+
const assessment = adaptRiskAssessment(input);
|
|
304
|
+
const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
|
|
305
|
+
if (hasCritical) {
|
|
306
|
+
layersFailed.push("L2_risk");
|
|
307
|
+
return {
|
|
308
|
+
status: "blocked_risk",
|
|
309
|
+
checklist_result: checklist,
|
|
310
|
+
risk_result: assessment,
|
|
311
|
+
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
312
|
+
block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
313
|
+
decision_record: {
|
|
314
|
+
timestamp: new Date().toISOString(),
|
|
315
|
+
gate_version: REWARD_CONFIRM_VERSION,
|
|
316
|
+
final_status: "blocked_risk",
|
|
317
|
+
layers_passed: layersPassed,
|
|
318
|
+
layers_failed: layersFailed,
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
layersPassed.push("L2_risk");
|
|
323
|
+
const userConf = processUserConfirmation(input, assessment);
|
|
324
|
+
if (!userConf.all_confirmed) {
|
|
325
|
+
if (input.reward_json.owner_receive != null) {
|
|
326
|
+
const cr09 = checklist.items.find(i => i.id === "C-R-09");
|
|
327
|
+
if (cr09) {
|
|
328
|
+
const qrw3 = userConf.responses.find(r => r.question_id === "QRW3");
|
|
329
|
+
cr09.passed = qrw3?.response === "yes";
|
|
330
|
+
cr09.message = cr09.passed ? "" : "owner_receive not confirmed by user (QRW3)";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (input.reward_json.owner_receive != null) {
|
|
334
|
+
const cr09 = checklist.items.find(i => i.id === "C-R-09");
|
|
335
|
+
if (cr09 && !cr09.passed) {
|
|
336
|
+
layersFailed.push("L3_user");
|
|
337
|
+
return {
|
|
338
|
+
status: "blocked_user",
|
|
339
|
+
checklist_result: checklist,
|
|
340
|
+
risk_result: assessment,
|
|
341
|
+
user_confirmation: userConf,
|
|
342
|
+
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
343
|
+
block_reason: "User did not confirm owner_receive (QRW3)",
|
|
344
|
+
decision_record: {
|
|
345
|
+
timestamp: new Date().toISOString(),
|
|
346
|
+
gate_version: REWARD_CONFIRM_VERSION,
|
|
347
|
+
final_status: "blocked_user",
|
|
348
|
+
layers_passed: layersPassed,
|
|
349
|
+
layers_failed: layersFailed,
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
layersPassed.push("L3_user");
|
|
356
|
+
if (input.skip_environment_check) {
|
|
357
|
+
layersPassed.push("L4_environment");
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
const env = verifyEnvironment(input);
|
|
361
|
+
if (!env.passed) {
|
|
362
|
+
layersFailed.push("L4_environment");
|
|
363
|
+
return {
|
|
364
|
+
status: "blocked_environment",
|
|
365
|
+
checklist_result: checklist,
|
|
366
|
+
risk_result: assessment,
|
|
367
|
+
user_confirmation: userConf,
|
|
368
|
+
environment_result: env,
|
|
369
|
+
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
370
|
+
block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
|
|
371
|
+
decision_record: {
|
|
372
|
+
timestamp: new Date().toISOString(),
|
|
373
|
+
gate_version: REWARD_CONFIRM_VERSION,
|
|
374
|
+
final_status: "blocked_environment",
|
|
375
|
+
layers_passed: layersPassed,
|
|
376
|
+
layers_failed: layersFailed,
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
layersPassed.push("L4_environment");
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
status: "approved",
|
|
384
|
+
checklist_result: checklist,
|
|
385
|
+
risk_result: assessment,
|
|
386
|
+
user_confirmation: userConf,
|
|
387
|
+
confirmation_text: generateConfirmationText(input, checklist, assessment),
|
|
388
|
+
decision_record: {
|
|
389
|
+
timestamp: new Date().toISOString(),
|
|
390
|
+
gate_version: REWARD_CONFIRM_VERSION,
|
|
391
|
+
final_status: "approved",
|
|
392
|
+
layers_passed: layersPassed,
|
|
393
|
+
layers_failed: layersFailed,
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function generateConfirmationText(input, checklist, assessment) {
|
|
398
|
+
const lines = [];
|
|
399
|
+
const data = input.reward_json;
|
|
400
|
+
lines.push("═══ Reward Operation Confirmation ═══");
|
|
401
|
+
lines.push("");
|
|
402
|
+
if (data.object) {
|
|
403
|
+
lines.push(`Reward: ${data.object}`);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
lines.push("Reward: NEW (will be created in this tx)");
|
|
407
|
+
}
|
|
408
|
+
if (input.reward_type) {
|
|
409
|
+
lines.push(`Coin type T: ${input.reward_type}`);
|
|
410
|
+
}
|
|
411
|
+
if (input.current_balance !== undefined) {
|
|
412
|
+
lines.push(`Current balance: ${input.current_balance}`);
|
|
413
|
+
}
|
|
414
|
+
if (input.current_guard_count !== undefined) {
|
|
415
|
+
lines.push(`Current guard count: ${input.current_guard_count}/${MAX_GUARD_COUNT_REWARD}`);
|
|
416
|
+
}
|
|
417
|
+
lines.push("");
|
|
418
|
+
lines.push("─ Checklist ──────────────────");
|
|
419
|
+
for (const item of checklist.items) {
|
|
420
|
+
const mark = item.passed ? "✓" : "✗";
|
|
421
|
+
lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
|
|
422
|
+
}
|
|
423
|
+
lines.push("");
|
|
424
|
+
if (assessment) {
|
|
425
|
+
lines.push("─ Risk Assessment ──────────────────");
|
|
426
|
+
lines.push(`Overall: ${assessment.overall_risk}`);
|
|
427
|
+
lines.push(`Detected: ${assessment.risks.length} risk(s)`);
|
|
428
|
+
for (const r of assessment.risks) {
|
|
429
|
+
lines.push(` [${r.level}] ${r.id}: ${r.title}`);
|
|
430
|
+
}
|
|
431
|
+
lines.push("");
|
|
432
|
+
}
|
|
433
|
+
lines.push("─ Operations ──────────────────");
|
|
434
|
+
if (data.claim)
|
|
435
|
+
lines.push(`- claim: guard=${data.claim} (passport-driven, no permission)`);
|
|
436
|
+
if (data.description != null)
|
|
437
|
+
lines.push(`- description_set: "${data.description}"`);
|
|
438
|
+
if (data.coin_add)
|
|
439
|
+
lines.push(`- coin_add: ${data.coin_add.amount} of ${data.coin_add.coin_type}`);
|
|
440
|
+
if (data.receive)
|
|
441
|
+
lines.push(`- receive: payment token=${data.receive.token_type}`);
|
|
442
|
+
if (data.guard_add) {
|
|
443
|
+
lines.push(`- guard_add: ${data.guard_add.length} guard(s)`);
|
|
444
|
+
for (let i = 0; i < data.guard_add.length; i++) {
|
|
445
|
+
const g = data.guard_add[i];
|
|
446
|
+
const rKey = Object.keys(g.recipient)[0];
|
|
447
|
+
lines.push(` [${i}] guard=${g.guard}, recipient=${rKey}, amount=${g.amount.type}(${g.amount.value})`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (data.guard_remove_expired)
|
|
451
|
+
lines.push(`- guard_remove_expired: true`);
|
|
452
|
+
if (data.guard_expiration_time !== undefined) {
|
|
453
|
+
const t = data.guard_expiration_time;
|
|
454
|
+
lines.push(`- guard_expiration_time_add: ${t === null ? "null (cancel lock)" : t}`);
|
|
455
|
+
}
|
|
456
|
+
if (data.owner_receive != null)
|
|
457
|
+
lines.push(`- ⚠️ owner_receive (156): unwrap to Permission owner`);
|
|
458
|
+
if (data.um !== undefined) {
|
|
459
|
+
lines.push(`- um_${data.um ? "set" : "none"}: ${data.um ?? "(unbind)"}`);
|
|
460
|
+
}
|
|
461
|
+
lines.push("");
|
|
462
|
+
return lines.join("\n");
|
|
463
|
+
}
|
|
464
|
+
export function progressiveRewardCheck(input) {
|
|
465
|
+
const checklist = runStaticChecklist(input);
|
|
466
|
+
if (!checklist.all_passed) {
|
|
467
|
+
return {
|
|
468
|
+
stage: "checklist",
|
|
469
|
+
status: "fail",
|
|
470
|
+
message: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
|
|
471
|
+
next_action: "Fix failing checklist items",
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const assessment = adaptRiskAssessment(input);
|
|
475
|
+
if (assessment.risks.some(r => r.level === "CRITICAL")) {
|
|
476
|
+
return {
|
|
477
|
+
stage: "risk",
|
|
478
|
+
status: "fail",
|
|
479
|
+
message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
|
|
480
|
+
next_action: "Resolve CRITICAL risks before proceeding",
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
if (assessment.needs_human_review) {
|
|
484
|
+
return {
|
|
485
|
+
stage: "confirmation",
|
|
486
|
+
status: "pending",
|
|
487
|
+
message: "Human review required for HIGH risks",
|
|
488
|
+
next_action: "Confirm risk acceptance",
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
stage: "complete",
|
|
493
|
+
status: "pass",
|
|
494
|
+
message: "All checks passed",
|
|
495
|
+
};
|
|
496
|
+
}
|