@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,96 @@
|
|
|
1
|
+
import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD } from "./onchain-constants.js";
|
|
2
|
+
export { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, };
|
|
3
|
+
export type RewardPhase = "creation" | "guard_addition" | "guard_lock_mgmt" | "funds_replenish" | "claim" | "um_mgmt" | "owner_receive" | "description_update" | "permission_update";
|
|
4
|
+
export interface RewardBuiltinPermissionEntry {
|
|
5
|
+
index: 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
governed_operations: string[];
|
|
9
|
+
sdk_exposed: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type RewardRecipientType = "GuardIdentifier" | "Entity" | "Signer";
|
|
12
|
+
export type RewardAmountType = "GuardU64Identifier" | "Fixed";
|
|
13
|
+
export type RewardGuardConstructor = "guard_u8_u8" | "guard_u8_u64" | "guard_entity_u8" | "guard_entity_u64" | "guard_signer_u8" | "guard_signer_u64";
|
|
14
|
+
export interface RewardGuardConstructorSpec {
|
|
15
|
+
constructor: RewardGuardConstructor;
|
|
16
|
+
recipient_type: RewardRecipientType;
|
|
17
|
+
amount_type: RewardAmountType;
|
|
18
|
+
params: {
|
|
19
|
+
recipient_param?: "u8" | "address";
|
|
20
|
+
amount_param: "u8" | "u64";
|
|
21
|
+
expiration_time: "Option<u64>";
|
|
22
|
+
store_from_id: "Option<u8>";
|
|
23
|
+
};
|
|
24
|
+
construction_checks: string[];
|
|
25
|
+
typical_use: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RewardScene {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
industry: string[];
|
|
31
|
+
scenario: string;
|
|
32
|
+
phases: RewardPhase[];
|
|
33
|
+
coin_type_note: string;
|
|
34
|
+
typical_guard_count: number;
|
|
35
|
+
recipient_types_used: RewardRecipientType[];
|
|
36
|
+
amount_types_used: RewardAmountType[];
|
|
37
|
+
uses_expiration_time: boolean;
|
|
38
|
+
uses_store_from_id: boolean;
|
|
39
|
+
builtin_indexes_consumed: RewardBuiltinPermissionEntry[];
|
|
40
|
+
common_patterns: string[];
|
|
41
|
+
recommended_templates: string[];
|
|
42
|
+
}
|
|
43
|
+
export declare const REWARD_NEW: RewardBuiltinPermissionEntry;
|
|
44
|
+
export declare const REWARD_DESCRIPTION: RewardBuiltinPermissionEntry;
|
|
45
|
+
export declare const REWARD_GUARD: RewardBuiltinPermissionEntry;
|
|
46
|
+
export declare const REWARD_COIN_ADD: RewardBuiltinPermissionEntry;
|
|
47
|
+
export declare const REWARD_RECEIVE: RewardBuiltinPermissionEntry;
|
|
48
|
+
export declare const REWARD_GUARD_EXPIRATION_TIME_ADD: RewardBuiltinPermissionEntry;
|
|
49
|
+
export declare const REWARD_OWNER_RECEIVE: RewardBuiltinPermissionEntry;
|
|
50
|
+
export declare const REWARD_UM: RewardBuiltinPermissionEntry;
|
|
51
|
+
export declare const REWARD_PERMISSIONS: RewardBuiltinPermissionEntry[];
|
|
52
|
+
export interface RewardFieldEntry {
|
|
53
|
+
name: string;
|
|
54
|
+
move_type: string;
|
|
55
|
+
mutability: "immutable" | "admin_mutable" | "runtime";
|
|
56
|
+
set_at_creation: boolean;
|
|
57
|
+
constraint: string;
|
|
58
|
+
permission_index?: number;
|
|
59
|
+
related_errors?: string[];
|
|
60
|
+
}
|
|
61
|
+
export declare const REWARD_FIELDS: RewardFieldEntry[];
|
|
62
|
+
export declare const REWARD_GUARD_CONSTRUCTORS: RewardGuardConstructorSpec[];
|
|
63
|
+
export interface RewardErrorCodeEntry {
|
|
64
|
+
code: number;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
trigger_operation: string;
|
|
68
|
+
}
|
|
69
|
+
export declare const REWARD_ERROR_CODES: RewardErrorCodeEntry[];
|
|
70
|
+
export declare const REWARD_SCENES: RewardScene[];
|
|
71
|
+
export declare const REWARD_LEDGER_VERSION = "1.0.0";
|
|
72
|
+
export declare function getScenesByPhase(phase: RewardPhase): RewardScene[];
|
|
73
|
+
export declare function findSceneById(id: string): RewardScene | undefined;
|
|
74
|
+
export declare function getScenesByIndustry(industry: string): RewardScene[];
|
|
75
|
+
export declare function getBuiltinPermissionByIndex(index: number): RewardBuiltinPermissionEntry | undefined;
|
|
76
|
+
export declare function isRewardBuiltinPermission(index: number): boolean;
|
|
77
|
+
export declare function getAllBuiltinPermissions(): RewardBuiltinPermissionEntry[];
|
|
78
|
+
export declare function getRewardScenesCount(): number;
|
|
79
|
+
export declare function getGuardConstructorSpec(constructor: RewardGuardConstructor): RewardGuardConstructorSpec | undefined;
|
|
80
|
+
export declare function resolveGuardConstructor(recipient_type: RewardRecipientType, amount_type: RewardAmountType): RewardGuardConstructor | undefined;
|
|
81
|
+
export declare function getRewardErrorByCode(code: number): RewardErrorCodeEntry | undefined;
|
|
82
|
+
export declare function getRewardErrorByName(name: string): RewardErrorCodeEntry | undefined;
|
|
83
|
+
export declare function validateGuardCount(currentGuardCount: number): {
|
|
84
|
+
ok: boolean;
|
|
85
|
+
violation?: string;
|
|
86
|
+
};
|
|
87
|
+
export declare function validateRecordCount(currentRecordCount: number): {
|
|
88
|
+
ok: boolean;
|
|
89
|
+
violation?: string;
|
|
90
|
+
};
|
|
91
|
+
export declare function inferSceneFromIntent(intent: string): RewardScene | undefined;
|
|
92
|
+
export declare const REWARD_CROSS_OBJECT_REFS: Array<{
|
|
93
|
+
object: "Guard" | "Permission" | "Passport" | "Payment" | "Repository" | "Service" | "Demand" | "Allocation" | "Contact" | "Coin";
|
|
94
|
+
phase: RewardPhase | "universal";
|
|
95
|
+
relationship: string;
|
|
96
|
+
}>;
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, } from "./onchain-constants.js";
|
|
2
|
+
export { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, };
|
|
3
|
+
export const REWARD_NEW = {
|
|
4
|
+
index: 150,
|
|
5
|
+
name: "REWARD_NEW",
|
|
6
|
+
description: "Create new Reward<T> (asserted by reward::new / new_with_passport)",
|
|
7
|
+
governed_operations: ["reward::new", "reward::new_with_passport"],
|
|
8
|
+
sdk_exposed: true,
|
|
9
|
+
};
|
|
10
|
+
export const REWARD_DESCRIPTION = {
|
|
11
|
+
index: 151,
|
|
12
|
+
name: "REWARD_DESCRIPTION",
|
|
13
|
+
description: "Update description (asserted by reward::description_set / _with_passport)",
|
|
14
|
+
governed_operations: ["reward::description_set", "reward::description_set_with_passport"],
|
|
15
|
+
sdk_exposed: true,
|
|
16
|
+
};
|
|
17
|
+
export const REWARD_GUARD = {
|
|
18
|
+
index: 152,
|
|
19
|
+
name: "REWARD_GUARD",
|
|
20
|
+
description: "Add / remove expired guards (≤ MAX_GUARD_COUNT_REWARD=200)",
|
|
21
|
+
governed_operations: [
|
|
22
|
+
"reward::guard_add",
|
|
23
|
+
"reward::guard_add_with_passport",
|
|
24
|
+
"reward::guard_remove_expired",
|
|
25
|
+
"reward::guard_remove_expired_with_passport",
|
|
26
|
+
],
|
|
27
|
+
sdk_exposed: true,
|
|
28
|
+
};
|
|
29
|
+
export const REWARD_COIN_ADD = {
|
|
30
|
+
index: 153,
|
|
31
|
+
name: "REWARD_COIN_ADD",
|
|
32
|
+
description: "Deposit Coin<T> directly into Reward balance (joins Balance<T>)",
|
|
33
|
+
governed_operations: ["reward::coin_add", "reward::coin_add_with_passport"],
|
|
34
|
+
sdk_exposed: true,
|
|
35
|
+
};
|
|
36
|
+
export const REWARD_RECEIVE = {
|
|
37
|
+
index: 154,
|
|
38
|
+
name: "REWARD_RECEIVE",
|
|
39
|
+
description: "Receive CoinWrapper<T> via Payment.unwrap_with_check (joins Balance<T>)",
|
|
40
|
+
governed_operations: ["reward::receive", "reward::receive_with_passport"],
|
|
41
|
+
sdk_exposed: true,
|
|
42
|
+
};
|
|
43
|
+
export const REWARD_GUARD_EXPIRATION_TIME_ADD = {
|
|
44
|
+
index: 155,
|
|
45
|
+
name: "REWARD_GUARD_EXPIRATION_TIME_ADD",
|
|
46
|
+
description: "Set / cancel guard_not_added_expiration_time (time-lock on new guard additions)",
|
|
47
|
+
governed_operations: [
|
|
48
|
+
"reward::guard_expiration_time_add",
|
|
49
|
+
"reward::guard_expiration_time_add_with_passport",
|
|
50
|
+
],
|
|
51
|
+
sdk_exposed: true,
|
|
52
|
+
};
|
|
53
|
+
export const REWARD_OWNER_RECEIVE = {
|
|
54
|
+
index: 156,
|
|
55
|
+
name: "REWARD_OWNER_RECEIVE",
|
|
56
|
+
description: "Owner receives Receiving<K> / CoinWrapper<K> at terminal state (unwrap → owner)",
|
|
57
|
+
governed_operations: [
|
|
58
|
+
"reward::owner_receive",
|
|
59
|
+
"reward::owner_receive_with_passport",
|
|
60
|
+
"reward::owner_receive_object",
|
|
61
|
+
"reward::owner_receive_object_with_passport",
|
|
62
|
+
],
|
|
63
|
+
sdk_exposed: true,
|
|
64
|
+
};
|
|
65
|
+
export const REWARD_UM = {
|
|
66
|
+
index: 157,
|
|
67
|
+
name: "REWARD_UM",
|
|
68
|
+
description: "Bind / unbind Contact (UM) for off-chain coordination",
|
|
69
|
+
governed_operations: [
|
|
70
|
+
"reward::um_set",
|
|
71
|
+
"reward::um_set_with_passport",
|
|
72
|
+
"reward::um_none",
|
|
73
|
+
"reward::um_none_with_passport",
|
|
74
|
+
],
|
|
75
|
+
sdk_exposed: true,
|
|
76
|
+
};
|
|
77
|
+
export const REWARD_PERMISSIONS = [
|
|
78
|
+
REWARD_NEW,
|
|
79
|
+
REWARD_DESCRIPTION,
|
|
80
|
+
REWARD_GUARD,
|
|
81
|
+
REWARD_COIN_ADD,
|
|
82
|
+
REWARD_RECEIVE,
|
|
83
|
+
REWARD_GUARD_EXPIRATION_TIME_ADD,
|
|
84
|
+
REWARD_OWNER_RECEIVE,
|
|
85
|
+
REWARD_UM,
|
|
86
|
+
];
|
|
87
|
+
export const REWARD_FIELDS = [
|
|
88
|
+
{
|
|
89
|
+
name: "id",
|
|
90
|
+
move_type: "UID",
|
|
91
|
+
mutability: "immutable",
|
|
92
|
+
set_at_creation: true,
|
|
93
|
+
constraint: "Object UID; assigned in new_imp via object::new(ctx). Never changes.",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "description",
|
|
97
|
+
move_type: "String",
|
|
98
|
+
mutability: "admin_mutable",
|
|
99
|
+
set_at_creation: true,
|
|
100
|
+
permission_index: 151,
|
|
101
|
+
constraint: "Must satisfy common::DESCRIPTION. Updated via description_set (151).",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "guards",
|
|
105
|
+
move_type: "vector<RewardGuard>",
|
|
106
|
+
mutability: "admin_mutable",
|
|
107
|
+
set_at_creation: true,
|
|
108
|
+
permission_index: 152,
|
|
109
|
+
constraint: "vector::length < MAX_GUARD_COUNT (200); E_GUARD_COUNT_EXCEEDED on overflow.",
|
|
110
|
+
related_errors: ["E_GUARD_COUNT_EXCEEDED"],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "balance",
|
|
114
|
+
move_type: "Balance<T>",
|
|
115
|
+
mutability: "runtime",
|
|
116
|
+
set_at_creation: true,
|
|
117
|
+
constraint: "Zero at creation (balance::zero()); grows via coin_add/receive; shrinks via claim (split) and never via direct withdraw.",
|
|
118
|
+
related_errors: ["E_INSUFFICIENT_BALANCE"],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "guard_not_added_expiration_time",
|
|
122
|
+
move_type: "Option<u64>",
|
|
123
|
+
mutability: "admin_mutable",
|
|
124
|
+
set_at_creation: true,
|
|
125
|
+
permission_index: 155,
|
|
126
|
+
constraint: "Option<timestamp_ms>. When Some(t): guard_add requires clock > t (E_GUARD_LOCKED_TIME). When None or t < now: guards can be added.",
|
|
127
|
+
related_errors: ["E_GUARD_LOCKED_TIME", "E_GUARD_LOCKED_TIME_NOT_INCREASING", "E_GUARD_LOCKED_TIME_INVALID"],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "record",
|
|
131
|
+
move_type: "ParentTable<address, RecipientRecord>",
|
|
132
|
+
mutability: "runtime",
|
|
133
|
+
set_at_creation: true,
|
|
134
|
+
constraint: "Per-recipient claim history. Each RecipientRecord.amount vector has length < MAX_RECORD_COUNT (5200); E_RECORD_COUNT_EXCEEDED on overflow.",
|
|
135
|
+
related_errors: ["E_RECORD_COUNT_EXCEEDED"],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "um",
|
|
139
|
+
move_type: "Option<address>",
|
|
140
|
+
mutability: "admin_mutable",
|
|
141
|
+
set_at_creation: true,
|
|
142
|
+
permission_index: 157,
|
|
143
|
+
constraint: "Option<Contact address>. um_set creates Registrar affiliation; um_none disaffiliates.",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "permission",
|
|
147
|
+
move_type: "address",
|
|
148
|
+
mutability: "admin_mutable",
|
|
149
|
+
set_at_creation: true,
|
|
150
|
+
constraint: "Permission object address. Updated via permission_set (asserts old.owner == sender). Creates Registrar affiliation_change.",
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
export const REWARD_GUARD_CONSTRUCTORS = [
|
|
154
|
+
{
|
|
155
|
+
constructor: "guard_u8_u8",
|
|
156
|
+
recipient_type: "GuardIdentifier",
|
|
157
|
+
amount_type: "GuardU64Identifier",
|
|
158
|
+
params: {
|
|
159
|
+
recipient_param: "u8",
|
|
160
|
+
amount_param: "u8",
|
|
161
|
+
expiration_time: "Option<u64>",
|
|
162
|
+
store_from_id: "Option<u8>",
|
|
163
|
+
},
|
|
164
|
+
construction_checks: [
|
|
165
|
+
"is_identifier_address(guard, recipient) — E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4)",
|
|
166
|
+
"get_submission_value_type(guard, amount) must be Some(TYPE_U64) — E_AMOUNT_NOT_U64 (5)",
|
|
167
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
168
|
+
],
|
|
169
|
+
typical_use: "Dynamic recipient + dynamic amount — both extracted from Passport at claim time (e.g. referral rewards where referrer and amount vary per claim).",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
constructor: "guard_u8_u64",
|
|
173
|
+
recipient_type: "GuardIdentifier",
|
|
174
|
+
amount_type: "Fixed",
|
|
175
|
+
params: {
|
|
176
|
+
recipient_param: "u8",
|
|
177
|
+
amount_param: "u64",
|
|
178
|
+
expiration_time: "Option<u64>",
|
|
179
|
+
store_from_id: "Option<u8>",
|
|
180
|
+
},
|
|
181
|
+
construction_checks: [
|
|
182
|
+
"is_identifier_address(guard, recipient) — E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4)",
|
|
183
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
184
|
+
],
|
|
185
|
+
typical_use: "Dynamic recipient + fixed amount — e.g. first-order reward where any new customer claims a fixed 1 WOW.",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
constructor: "guard_entity_u8",
|
|
189
|
+
recipient_type: "Entity",
|
|
190
|
+
amount_type: "GuardU64Identifier",
|
|
191
|
+
params: {
|
|
192
|
+
recipient_param: "address",
|
|
193
|
+
amount_param: "u8",
|
|
194
|
+
expiration_time: "Option<u64>",
|
|
195
|
+
store_from_id: "Option<u8>",
|
|
196
|
+
},
|
|
197
|
+
construction_checks: [
|
|
198
|
+
"get_submission_value_type(guard, amount) must be Some(TYPE_U64) — E_AMOUNT_NOT_U64 (5)",
|
|
199
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
200
|
+
],
|
|
201
|
+
typical_use: "Fixed recipient + dynamic amount — e.g. tiered loyalty reward where amount depends on Passport submission (tier level).",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
constructor: "guard_entity_u64",
|
|
205
|
+
recipient_type: "Entity",
|
|
206
|
+
amount_type: "Fixed",
|
|
207
|
+
params: {
|
|
208
|
+
recipient_param: "address",
|
|
209
|
+
amount_param: "u64",
|
|
210
|
+
expiration_time: "Option<u64>",
|
|
211
|
+
store_from_id: "Option<u8>",
|
|
212
|
+
},
|
|
213
|
+
construction_checks: [
|
|
214
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
215
|
+
],
|
|
216
|
+
typical_use: "Fully fixed recipient + amount — simplest configuration (e.g. specific partner bounty).",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
constructor: "guard_signer_u8",
|
|
220
|
+
recipient_type: "Signer",
|
|
221
|
+
amount_type: "GuardU64Identifier",
|
|
222
|
+
params: {
|
|
223
|
+
amount_param: "u8",
|
|
224
|
+
expiration_time: "Option<u64>",
|
|
225
|
+
store_from_id: "Option<u8>",
|
|
226
|
+
},
|
|
227
|
+
construction_checks: [
|
|
228
|
+
"get_submission_value_type(guard, amount) must be Some(TYPE_U64) — E_AMOUNT_NOT_U64 (5)",
|
|
229
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
230
|
+
],
|
|
231
|
+
typical_use: "Caller is recipient + dynamic amount — e.g. self-service claim where amount depends on Passport submission (e.g. cashback rate).",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
constructor: "guard_signer_u64",
|
|
235
|
+
recipient_type: "Signer",
|
|
236
|
+
amount_type: "Fixed",
|
|
237
|
+
params: {
|
|
238
|
+
amount_param: "u64",
|
|
239
|
+
expiration_time: "Option<u64>",
|
|
240
|
+
store_from_id: "Option<u8>",
|
|
241
|
+
},
|
|
242
|
+
construction_checks: [
|
|
243
|
+
"if store_from_id is Some: is_identifier_address_compatible — E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
244
|
+
],
|
|
245
|
+
typical_use: "Caller is recipient + fixed amount — e.g. flash sale where any eligible caller claims a fixed reward.",
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
export const REWARD_ERROR_CODES = [
|
|
249
|
+
{ code: 1, name: "E_GUARD_LOCKED_TIME_NOT_INCREASING", description: "guard_expiration_time_add: new time < current clock (must be ≥ now)", trigger_operation: "guard_expiration_time_add" },
|
|
250
|
+
{ code: 2, name: "E_GUARD_EXPIRED", description: "guard_add on guard with expiration_time < now, OR claim on guard with expiration_time < now", trigger_operation: "guard_add / claim" },
|
|
251
|
+
{ code: 3, name: "E_GUARD_COUNT_EXCEEDED", description: "guard_add would exceed MAX_GUARD_COUNT=200 (only on NEW guard, not on update of existing)", trigger_operation: "guard_add" },
|
|
252
|
+
{ code: 4, name: "E_RECIPIENT_IDENTIFIER_NOT_ADDRESS", description: "RewardGuard constructor: recipient identifier type is not address (GuardIdentifier variant only)", trigger_operation: "reward_guard (constructor)" },
|
|
253
|
+
{ code: 5, name: "E_AMOUNT_NOT_U64", description: "RewardGuard constructor: amount identifier type is not u64 (GuardU64Identifier variant only)", trigger_operation: "reward_guard (constructor)" },
|
|
254
|
+
{ code: 6, name: "E_INSUFFICIENT_BALANCE", description: "claim: balance < amount (cannot split more than held)", trigger_operation: "claim" },
|
|
255
|
+
{ code: 7, name: "E_GUARD_NOT_FOUND", description: "claim: no guard in self.guards matches the supplied guard address", trigger_operation: "claim" },
|
|
256
|
+
{ code: 8, name: "E_RECORD_COUNT_EXCEEDED", description: "claim: recipient already has MAX_RECORD_COUNT=5200 entries (E_RECORD_COUNT_EXCEEDED)", trigger_operation: "claim" },
|
|
257
|
+
{ code: 10, name: "E_GUARD_LOCKED_TIME", description: "guard_add while guard_not_added_expiration_time is Some and clock ≤ expiration_time", trigger_operation: "guard_add" },
|
|
258
|
+
{ code: 11, name: "E_GUARD_LOCKED_TIME_INVALID", description: "guard_expiration_time_add: new Some(t) where t ≤ now (must be future)", trigger_operation: "guard_expiration_time_add" },
|
|
259
|
+
{ code: 12, name: "E_STORE_FROM_ID_NOT_COMPATIBLE", description: "RewardGuard constructor: store_from_id identifier type is not number or address", trigger_operation: "reward_guard (constructor)" },
|
|
260
|
+
];
|
|
261
|
+
export const REWARD_SCENES = [
|
|
262
|
+
{
|
|
263
|
+
id: "reward_first_order",
|
|
264
|
+
name: "First-order reward",
|
|
265
|
+
industry: ["universal", "ecommerce", "service", "freelance"],
|
|
266
|
+
scenario: "New customers receive a fixed reward after their first order. Guard verifies order ownership + first-time status; " +
|
|
267
|
+
"Recipient=Signer (caller is the new customer); Amount=Fixed (e.g. 1 WOW).",
|
|
268
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim"],
|
|
269
|
+
coin_type_note: "T = project reward coin (e.g. 0x2::wow::WOW or a custom token)",
|
|
270
|
+
typical_guard_count: 1,
|
|
271
|
+
recipient_types_used: ["Signer"],
|
|
272
|
+
amount_types_used: ["Fixed"],
|
|
273
|
+
uses_expiration_time: true,
|
|
274
|
+
uses_store_from_id: false,
|
|
275
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD],
|
|
276
|
+
common_patterns: [
|
|
277
|
+
"guard_signer_u64 — caller claims a fixed amount (e.g. 1 WOW)",
|
|
278
|
+
"Guard verifies: order_address.holder == signer AND order is the first order (Repository query)",
|
|
279
|
+
"expiration_time bounds the campaign window (e.g. 30 days)",
|
|
280
|
+
"coin_add deposits the campaign budget upfront (e.g. 100 WOW for 100 claims)",
|
|
281
|
+
],
|
|
282
|
+
recommended_templates: ["first_order"],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
id: "reward_referral",
|
|
286
|
+
name: "Referral viral reward",
|
|
287
|
+
industry: ["universal", "ecommerce", "service", "content"],
|
|
288
|
+
scenario: "Both referrer and referee receive a reward when the referee completes a first order. Two guards: one for referrer (Entity), one for referee (Signer).",
|
|
289
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim"],
|
|
290
|
+
coin_type_note: "T = project reward coin",
|
|
291
|
+
typical_guard_count: 2,
|
|
292
|
+
recipient_types_used: ["Entity", "Signer"],
|
|
293
|
+
amount_types_used: ["Fixed"],
|
|
294
|
+
uses_expiration_time: true,
|
|
295
|
+
uses_store_from_id: true,
|
|
296
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD],
|
|
297
|
+
common_patterns: [
|
|
298
|
+
"guard_entity_u64 for referrer (recipient = referrer address, fixed amount)",
|
|
299
|
+
"guard_signer_u64 for referee (caller is recipient, fixed amount)",
|
|
300
|
+
"Guard verifies: referrer marked in Repository AND referee's order completed",
|
|
301
|
+
"store_from_id may record the order address for audit trail",
|
|
302
|
+
],
|
|
303
|
+
recommended_templates: ["referral"],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: "reward_loyalty",
|
|
307
|
+
name: "Loyalty tiered reward",
|
|
308
|
+
industry: ["universal", "ecommerce", "subscription", "content"],
|
|
309
|
+
scenario: "Customers unlock higher rewards after reaching cumulative spending tiers. Recipient=Signer; Amount=GuardU64Identifier (tier-dependent amount extracted from Passport).",
|
|
310
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim"],
|
|
311
|
+
coin_type_note: "T = project reward coin",
|
|
312
|
+
typical_guard_count: 1,
|
|
313
|
+
recipient_types_used: ["Signer"],
|
|
314
|
+
amount_types_used: ["GuardU64Identifier"],
|
|
315
|
+
uses_expiration_time: false,
|
|
316
|
+
uses_store_from_id: false,
|
|
317
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD],
|
|
318
|
+
common_patterns: [
|
|
319
|
+
"guard_signer_u8 — amount is dynamic, extracted from Passport submission (tier level → reward amount)",
|
|
320
|
+
"Guard verifies: cumulative spend ≥ tier threshold (Repository query)",
|
|
321
|
+
"No expiration_time — loyalty is perpetual (until deactivated via guard_remove_expired)",
|
|
322
|
+
"Guard submission value type MUST be u64 (E_AMOUNT_NOT_U64 otherwise)",
|
|
323
|
+
],
|
|
324
|
+
recommended_templates: ["loyalty"],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
id: "reward_flash_sale",
|
|
328
|
+
name: "Limited-time flash sale reward",
|
|
329
|
+
industry: ["universal", "ecommerce", "retail"],
|
|
330
|
+
scenario: "Time-bounded reward for the first N callers. Recipient=Signer; Amount=Fixed. Guard verifies time window + claim count.",
|
|
331
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim", "guard_lock_mgmt"],
|
|
332
|
+
coin_type_note: "T = project reward coin",
|
|
333
|
+
typical_guard_count: 1,
|
|
334
|
+
recipient_types_used: ["Signer"],
|
|
335
|
+
amount_types_used: ["Fixed"],
|
|
336
|
+
uses_expiration_time: true,
|
|
337
|
+
uses_store_from_id: false,
|
|
338
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD, REWARD_GUARD_EXPIRATION_TIME_ADD],
|
|
339
|
+
common_patterns: [
|
|
340
|
+
"guard_signer_u64 — fixed amount per claim (e.g. 2 WOW)",
|
|
341
|
+
"expiration_time bounds the flash sale window (e.g. 48 hours)",
|
|
342
|
+
"guard_expiration_time_add (155) may lock further guard additions during the sale",
|
|
343
|
+
"Budget = max_claims × amount; coin_add deposits this upfront",
|
|
344
|
+
],
|
|
345
|
+
recommended_templates: ["flash_sale"],
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
id: "reward_bulk_discount",
|
|
349
|
+
name: "Bulk discount / cashback reward",
|
|
350
|
+
industry: ["universal", "ecommerce", "wholesale", "service"],
|
|
351
|
+
scenario: "Customer receives cashback proportional to order size. Recipient=Signer or Entity (order holder); Amount=GuardU64Identifier (cashback rate from Passport).",
|
|
352
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim"],
|
|
353
|
+
coin_type_note: "T = payment coin type (must match order payment for clean cashback)",
|
|
354
|
+
typical_guard_count: 1,
|
|
355
|
+
recipient_types_used: ["Signer", "Entity"],
|
|
356
|
+
amount_types_used: ["GuardU64Identifier"],
|
|
357
|
+
uses_expiration_time: false,
|
|
358
|
+
uses_store_from_id: true,
|
|
359
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD, REWARD_RECEIVE],
|
|
360
|
+
common_patterns: [
|
|
361
|
+
"guard_signer_u8 — caller claims dynamic amount (cashback = order_amount × rate)",
|
|
362
|
+
"store_from_id records the order address for cross-reference (audit trail)",
|
|
363
|
+
"receive (154) may be used to accept CoinWrapper<T> refunds that replenish the balance",
|
|
364
|
+
"Guard verifies: order.completed AND order.service == this Service",
|
|
365
|
+
],
|
|
366
|
+
recommended_templates: ["cashback"],
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: "reward_milestone",
|
|
370
|
+
name: "Service milestone reward",
|
|
371
|
+
industry: ["universal", "ecommerce", "content", "subscription"],
|
|
372
|
+
scenario: "When a Service reaches a milestone (e.g. 100 orders), early supporters receive extra rewards. Recipient=Entity (early customer); Amount=Fixed.",
|
|
373
|
+
phases: ["creation", "guard_addition", "funds_replenish", "claim", "guard_lock_mgmt"],
|
|
374
|
+
coin_type_note: "T = project reward coin",
|
|
375
|
+
typical_guard_count: 50,
|
|
376
|
+
recipient_types_used: ["Entity"],
|
|
377
|
+
amount_types_used: ["Fixed"],
|
|
378
|
+
uses_expiration_time: true,
|
|
379
|
+
uses_store_from_id: false,
|
|
380
|
+
builtin_indexes_consumed: [REWARD_NEW, REWARD_GUARD, REWARD_COIN_ADD, REWARD_GUARD_EXPIRATION_TIME_ADD],
|
|
381
|
+
common_patterns: [
|
|
382
|
+
"guard_entity_u64 for each early customer (recipient = customer address, fixed amount)",
|
|
383
|
+
"Multiple guards (up to 50 for 50 early supporters) — well within MAX_GUARD_COUNT=200",
|
|
384
|
+
"Guard verifies: Service order_count >= milestone AND claimer is in early-customer list",
|
|
385
|
+
"guard_expiration_time_add (155) may lock the guard list after milestone setup",
|
|
386
|
+
],
|
|
387
|
+
recommended_templates: ["milestone"],
|
|
388
|
+
},
|
|
389
|
+
];
|
|
390
|
+
export const REWARD_LEDGER_VERSION = "1.0.0";
|
|
391
|
+
export function getScenesByPhase(phase) {
|
|
392
|
+
return REWARD_SCENES.filter(s => s.phases.includes(phase));
|
|
393
|
+
}
|
|
394
|
+
export function findSceneById(id) {
|
|
395
|
+
return REWARD_SCENES.find(s => s.id === id);
|
|
396
|
+
}
|
|
397
|
+
export function getScenesByIndustry(industry) {
|
|
398
|
+
return REWARD_SCENES.filter(s => s.industry.includes(industry) || s.industry.includes("universal"));
|
|
399
|
+
}
|
|
400
|
+
export function getBuiltinPermissionByIndex(index) {
|
|
401
|
+
return REWARD_PERMISSIONS.find(p => p.index === index);
|
|
402
|
+
}
|
|
403
|
+
export function isRewardBuiltinPermission(index) {
|
|
404
|
+
return getBuiltinPermissionByIndex(index) !== undefined;
|
|
405
|
+
}
|
|
406
|
+
export function getAllBuiltinPermissions() {
|
|
407
|
+
return [...REWARD_PERMISSIONS];
|
|
408
|
+
}
|
|
409
|
+
export function getRewardScenesCount() {
|
|
410
|
+
return REWARD_SCENES.length;
|
|
411
|
+
}
|
|
412
|
+
export function getGuardConstructorSpec(constructor) {
|
|
413
|
+
return REWARD_GUARD_CONSTRUCTORS.find(c => c.constructor === constructor);
|
|
414
|
+
}
|
|
415
|
+
export function resolveGuardConstructor(recipient_type, amount_type) {
|
|
416
|
+
const map = {
|
|
417
|
+
"GuardIdentifier|GuardU64Identifier": "guard_u8_u8",
|
|
418
|
+
"GuardIdentifier|Fixed": "guard_u8_u64",
|
|
419
|
+
"Entity|GuardU64Identifier": "guard_entity_u8",
|
|
420
|
+
"Entity|Fixed": "guard_entity_u64",
|
|
421
|
+
"Signer|GuardU64Identifier": "guard_signer_u8",
|
|
422
|
+
"Signer|Fixed": "guard_signer_u64",
|
|
423
|
+
};
|
|
424
|
+
return map[`${recipient_type}|${amount_type}`];
|
|
425
|
+
}
|
|
426
|
+
export function getRewardErrorByCode(code) {
|
|
427
|
+
return REWARD_ERROR_CODES.find(e => e.code === code);
|
|
428
|
+
}
|
|
429
|
+
export function getRewardErrorByName(name) {
|
|
430
|
+
return REWARD_ERROR_CODES.find(e => e.name === name);
|
|
431
|
+
}
|
|
432
|
+
export function validateGuardCount(currentGuardCount) {
|
|
433
|
+
if (currentGuardCount >= MAX_GUARD_COUNT_REWARD) {
|
|
434
|
+
return {
|
|
435
|
+
ok: false,
|
|
436
|
+
violation: `Guard count ${currentGuardCount} would exceed MAX_GUARD_COUNT_REWARD ${MAX_GUARD_COUNT_REWARD}`,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
return { ok: true };
|
|
440
|
+
}
|
|
441
|
+
export function validateRecordCount(currentRecordCount) {
|
|
442
|
+
if (currentRecordCount >= MAX_RECORD_COUNT_REWARD) {
|
|
443
|
+
return {
|
|
444
|
+
ok: false,
|
|
445
|
+
violation: `Record count ${currentRecordCount} would exceed MAX_RECORD_COUNT_REWARD ${MAX_RECORD_COUNT_REWARD} — recipient can no longer claim`,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
return { ok: true };
|
|
449
|
+
}
|
|
450
|
+
export function inferSceneFromIntent(intent) {
|
|
451
|
+
const lower = intent.toLowerCase();
|
|
452
|
+
const keywordMap = [
|
|
453
|
+
["flash sale", "reward_flash_sale"],
|
|
454
|
+
["flash_sale", "reward_flash_sale"],
|
|
455
|
+
["limited-time", "reward_flash_sale"],
|
|
456
|
+
["limited time", "reward_flash_sale"],
|
|
457
|
+
["referral", "reward_referral"],
|
|
458
|
+
["viral", "reward_referral"],
|
|
459
|
+
["refer a friend", "reward_referral"],
|
|
460
|
+
["invite", "reward_referral"],
|
|
461
|
+
["loyalty", "reward_loyalty"],
|
|
462
|
+
["tiered", "reward_loyalty"],
|
|
463
|
+
["tier", "reward_loyalty"],
|
|
464
|
+
["repeat", "reward_loyalty"],
|
|
465
|
+
["cashback", "reward_bulk_discount"],
|
|
466
|
+
["bulk discount", "reward_bulk_discount"],
|
|
467
|
+
["bulk_discount", "reward_bulk_discount"],
|
|
468
|
+
["wholesale", "reward_bulk_discount"],
|
|
469
|
+
["milestone", "reward_milestone"],
|
|
470
|
+
["early supporter", "reward_milestone"],
|
|
471
|
+
["early customer", "reward_milestone"],
|
|
472
|
+
["first order", "reward_first_order"],
|
|
473
|
+
["first_order", "reward_first_order"],
|
|
474
|
+
["new customer", "reward_first_order"],
|
|
475
|
+
["first-time", "reward_first_order"],
|
|
476
|
+
];
|
|
477
|
+
for (const [kw, sceneId] of keywordMap) {
|
|
478
|
+
if (lower.includes(kw)) {
|
|
479
|
+
const scene = findSceneById(sceneId);
|
|
480
|
+
if (scene)
|
|
481
|
+
return scene;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
export const REWARD_CROSS_OBJECT_REFS = [
|
|
487
|
+
{ object: "Permission", phase: "universal", relationship: "Reward.permission (address; borrowed for all 150-157 assertions)" },
|
|
488
|
+
{ object: "Permission", phase: "permission_update", relationship: "permission_set: asserts old.owner == sender; creates Registrar affiliation_change" },
|
|
489
|
+
{ object: "Guard", phase: "guard_addition", relationship: "RewardGuard.guard = guard.id_address (each guard registered via Registrar affiliation)" },
|
|
490
|
+
{ object: "Guard", phase: "claim", relationship: "claim: iterates self.guards looking for guard.id_address match; E_GUARD_NOT_FOUND if no match" },
|
|
491
|
+
{ object: "Guard", phase: "claim", relationship: "claim: passport::result_for_guard(passport, guard_id) verifies submission data" },
|
|
492
|
+
{ object: "Passport", phase: "claim", relationship: "claim: passport::submission_get extracts recipient (address) and/or amount (u64) per RewardGuard variant" },
|
|
493
|
+
{ object: "Passport", phase: "claim", relationship: "claim: if store_from_id is Some, extracts store-from address from Passport submission" },
|
|
494
|
+
{ object: "Payment", phase: "funds_replenish", relationship: "receive (154): Payment.unwrap_with_check extracts Coin<T> from CoinWrapper<T> and joins balance" },
|
|
495
|
+
{ object: "Payment", phase: "owner_receive", relationship: "owner_receive (156): Payment.unwrap_with_check forwards CoinWrapper<K> to Permission owner" },
|
|
496
|
+
{ object: "Repository", phase: "claim", relationship: "Guard may query Repository (e.g. order history for first-order / loyalty verification)" },
|
|
497
|
+
{ object: "Service", phase: "claim", relationship: "Guard may verify order.service == this Service (cashback / first-order scenarios)" },
|
|
498
|
+
{ object: "Demand", phase: "guard_addition", relationship: "Guard may be shared with Demand (recommendation filtering); same Guard object address space" },
|
|
499
|
+
{ object: "Allocation", phase: "owner_receive", relationship: "Terminal Allocation alloc may route funds back to Reward (replenishment loop)" },
|
|
500
|
+
{ object: "Contact", phase: "um_mgmt", relationship: "um_set (157): binds Contact (UM) for off-chain coordination; creates Registrar affiliation" },
|
|
501
|
+
{ object: "Coin", phase: "universal", relationship: "Reward<phantom T>: T is the coin type; balance: Balance<T>; coin_add expects Coin<T>" },
|
|
502
|
+
];
|