@agirails/sdk 2.2.0 → 2.2.2
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/ACTPClient.d.ts +200 -0
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +266 -2
- package/dist/ACTPClient.js.map +1 -1
- package/dist/abi/ACTPKernel.json +16 -0
- package/dist/adapters/AdapterRegistry.d.ts +140 -0
- package/dist/adapters/AdapterRegistry.d.ts.map +1 -0
- package/dist/adapters/AdapterRegistry.js +166 -0
- package/dist/adapters/AdapterRegistry.js.map +1 -0
- package/dist/adapters/AdapterRouter.d.ts +165 -0
- package/dist/adapters/AdapterRouter.d.ts.map +1 -0
- package/dist/adapters/AdapterRouter.js +350 -0
- package/dist/adapters/AdapterRouter.js.map +1 -0
- package/dist/adapters/BaseAdapter.d.ts +17 -0
- package/dist/adapters/BaseAdapter.d.ts.map +1 -1
- package/dist/adapters/BaseAdapter.js +21 -0
- package/dist/adapters/BaseAdapter.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +72 -3
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +170 -2
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/IAdapter.d.ts +230 -0
- package/dist/adapters/IAdapter.d.ts.map +1 -0
- package/dist/adapters/IAdapter.js +44 -0
- package/dist/adapters/IAdapter.js.map +1 -0
- package/dist/adapters/StandardAdapter.d.ts +70 -1
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +184 -0
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/adapters/X402Adapter.d.ts +208 -0
- package/dist/adapters/X402Adapter.d.ts.map +1 -0
- package/dist/adapters/X402Adapter.js +423 -0
- package/dist/adapters/X402Adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +8 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +19 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +4 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +184 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/config/networks.js +3 -3
- package/dist/config/networks.js.map +1 -1
- package/dist/erc8004/ERC8004Bridge.d.ts +155 -0
- package/dist/erc8004/ERC8004Bridge.d.ts.map +1 -0
- package/dist/erc8004/ERC8004Bridge.js +325 -0
- package/dist/erc8004/ERC8004Bridge.js.map +1 -0
- package/dist/erc8004/ReputationReporter.d.ts +223 -0
- package/dist/erc8004/ReputationReporter.d.ts.map +1 -0
- package/dist/erc8004/ReputationReporter.js +266 -0
- package/dist/erc8004/ReputationReporter.js.map +1 -0
- package/dist/erc8004/index.d.ts +36 -0
- package/dist/erc8004/index.d.ts.map +1 -0
- package/dist/erc8004/index.js +46 -0
- package/dist/erc8004/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/protocol/ACTPKernel.d.ts +1 -1
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +16 -7
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +2 -0
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +6 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.d.ts +12 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.js +41 -0
- package/dist/runtime/MockRuntime.js.map +1 -1
- package/dist/runtime/types/MockState.d.ts +6 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -1
- package/dist/runtime/types/MockState.js.map +1 -1
- package/dist/types/adapter.d.ts +359 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/adapter.js +115 -0
- package/dist/types/adapter.js.map +1 -0
- package/dist/types/erc8004.d.ts +184 -0
- package/dist/types/erc8004.d.ts.map +1 -0
- package/dist/types/erc8004.js +132 -0
- package/dist/types/erc8004.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/transaction.d.ts +12 -0
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist/types/x402.d.ts +162 -0
- package/dist/types/x402.d.ts.map +1 -0
- package/dist/types/x402.js +162 -0
- package/dist/types/x402.js.map +1 -0
- package/package.json +3 -2
- package/src/ACTPClient.ts +318 -2
- package/src/abi/ACTPKernel.json +16 -0
- package/src/adapters/AdapterRegistry.ts +173 -0
- package/src/adapters/AdapterRouter.ts +417 -0
- package/src/adapters/BaseAdapter.ts +25 -0
- package/src/adapters/BasicAdapter.ts +199 -3
- package/src/adapters/IAdapter.ts +292 -0
- package/src/adapters/StandardAdapter.ts +220 -1
- package/src/adapters/X402Adapter.ts +653 -0
- package/src/adapters/index.ts +27 -0
- package/src/cli/commands/init.ts +208 -3
- package/src/config/networks.ts +3 -3
- package/src/erc8004/ERC8004Bridge.ts +461 -0
- package/src/erc8004/ReputationReporter.ts +472 -0
- package/src/erc8004/index.ts +61 -0
- package/src/index.ts +43 -0
- package/src/protocol/ACTPKernel.ts +26 -7
- package/src/runtime/BlockchainRuntime.ts +2 -0
- package/src/runtime/IACTPRuntime.ts +6 -0
- package/src/runtime/MockRuntime.ts +42 -0
- package/src/runtime/types/MockState.ts +7 -0
- package/src/types/adapter.ts +296 -0
- package/src/types/erc8004.ts +293 -0
- package/src/types/index.ts +3 -0
- package/src/types/transaction.ts +12 -0
- package/src/types/x402.ts +219 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter types for the ACTP SDK adapter routing system.
|
|
3
|
+
*
|
|
4
|
+
* This module defines types and Zod schemas for:
|
|
5
|
+
* - AdapterMetadata: Capabilities and configuration for each adapter
|
|
6
|
+
* - PaymentMetadata: Request-level hints for adapter selection
|
|
7
|
+
* - UnifiedPayParams: Common payment parameters across adapters
|
|
8
|
+
* - UnifiedPayResult: Common result type for all adapters
|
|
9
|
+
*
|
|
10
|
+
* @module types/adapter
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/**
|
|
14
|
+
* Metadata describing an adapter's capabilities.
|
|
15
|
+
*
|
|
16
|
+
* CRITICAL: All adapters must respect ACTP state machine:
|
|
17
|
+
* - No skipping IN_PROGRESS state
|
|
18
|
+
* - DELIVERED requires proof
|
|
19
|
+
* - releaseEscrow must be called explicitly (NO auto-settle)
|
|
20
|
+
*/
|
|
21
|
+
export interface AdapterMetadata {
|
|
22
|
+
/** Unique adapter identifier */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Human-readable name */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Whether adapter uses escrow */
|
|
27
|
+
usesEscrow: boolean;
|
|
28
|
+
/** Whether adapter supports dispute resolution */
|
|
29
|
+
supportsDisputes: boolean;
|
|
30
|
+
/** Whether adapter requires on-chain identity */
|
|
31
|
+
requiresIdentity: boolean;
|
|
32
|
+
/** Supported identity types (erc8004, did, ens) */
|
|
33
|
+
supportedIdentityTypes?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Settlement mode:
|
|
36
|
+
* - 'explicit': caller must call releaseEscrow (REQUIRED for ACTP compliance)
|
|
37
|
+
* - 'timed': auto-release after dispute window (future, not Phase 1)
|
|
38
|
+
* - 'atomic': instant settlement, no escrow (x402 protocol)
|
|
39
|
+
*/
|
|
40
|
+
settlementMode: 'explicit' | 'timed' | 'atomic';
|
|
41
|
+
/** Priority for auto-selection (higher = preferred) */
|
|
42
|
+
priority: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Zod schema for AdapterMetadata runtime validation.
|
|
46
|
+
*/
|
|
47
|
+
export declare const AdapterMetadataSchema: z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
usesEscrow: z.ZodBoolean;
|
|
51
|
+
supportsDisputes: z.ZodBoolean;
|
|
52
|
+
requiresIdentity: z.ZodBoolean;
|
|
53
|
+
supportedIdentityTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
54
|
+
settlementMode: z.ZodEnum<["explicit", "timed", "atomic"]>;
|
|
55
|
+
priority: z.ZodNumber;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
usesEscrow: boolean;
|
|
60
|
+
supportsDisputes: boolean;
|
|
61
|
+
requiresIdentity: boolean;
|
|
62
|
+
settlementMode: "explicit" | "timed" | "atomic";
|
|
63
|
+
priority: number;
|
|
64
|
+
supportedIdentityTypes?: string[] | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
usesEscrow: boolean;
|
|
69
|
+
supportsDisputes: boolean;
|
|
70
|
+
requiresIdentity: boolean;
|
|
71
|
+
settlementMode: "explicit" | "timed" | "atomic";
|
|
72
|
+
priority: number;
|
|
73
|
+
supportedIdentityTypes?: string[] | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Identity information for adapter selection.
|
|
77
|
+
*/
|
|
78
|
+
export interface PaymentIdentity {
|
|
79
|
+
type: 'erc8004' | 'did' | 'ens' | 'address';
|
|
80
|
+
value: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Payment request metadata for adapter selection.
|
|
84
|
+
*/
|
|
85
|
+
export interface PaymentMetadata {
|
|
86
|
+
/** Explicitly request specific adapter */
|
|
87
|
+
preferredAdapter?: string;
|
|
88
|
+
/** Require escrow protection */
|
|
89
|
+
requiresEscrow?: boolean;
|
|
90
|
+
/** Require dispute resolution capability */
|
|
91
|
+
requiresDispute?: boolean;
|
|
92
|
+
/** Identity information */
|
|
93
|
+
identity?: PaymentIdentity;
|
|
94
|
+
/** x402 specific: payment method hint */
|
|
95
|
+
paymentMethod?: 'x402' | 'actp' | 'auto';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Zod schema for PaymentIdentity runtime validation.
|
|
99
|
+
*/
|
|
100
|
+
export declare const PaymentIdentitySchema: z.ZodObject<{
|
|
101
|
+
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
102
|
+
value: z.ZodString;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
105
|
+
value: string;
|
|
106
|
+
}, {
|
|
107
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
108
|
+
value: string;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Zod schema for PaymentMetadata runtime validation.
|
|
112
|
+
*/
|
|
113
|
+
export declare const PaymentMetadataSchema: z.ZodObject<{
|
|
114
|
+
preferredAdapter: z.ZodOptional<z.ZodString>;
|
|
115
|
+
requiresEscrow: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
requiresDispute: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
118
|
+
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
119
|
+
value: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
122
|
+
value: string;
|
|
123
|
+
}, {
|
|
124
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
125
|
+
value: string;
|
|
126
|
+
}>>;
|
|
127
|
+
paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
preferredAdapter?: string | undefined;
|
|
130
|
+
requiresEscrow?: boolean | undefined;
|
|
131
|
+
requiresDispute?: boolean | undefined;
|
|
132
|
+
identity?: {
|
|
133
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
134
|
+
value: string;
|
|
135
|
+
} | undefined;
|
|
136
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
preferredAdapter?: string | undefined;
|
|
139
|
+
requiresEscrow?: boolean | undefined;
|
|
140
|
+
requiresDispute?: boolean | undefined;
|
|
141
|
+
identity?: {
|
|
142
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
143
|
+
value: string;
|
|
144
|
+
} | undefined;
|
|
145
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Unified payment parameters accepted by all adapters.
|
|
149
|
+
*/
|
|
150
|
+
export interface UnifiedPayParams {
|
|
151
|
+
/** Recipient - address, HTTP endpoint, or ERC-8004 agent ID */
|
|
152
|
+
to: string;
|
|
153
|
+
/** Amount in human-readable format */
|
|
154
|
+
amount: string | number;
|
|
155
|
+
/** Deadline (relative like '+24h' or unix timestamp) */
|
|
156
|
+
deadline?: string | number;
|
|
157
|
+
/** Dispute window in seconds (min 3600, max 30 days) */
|
|
158
|
+
disputeWindow?: number;
|
|
159
|
+
/** Service description */
|
|
160
|
+
description?: string;
|
|
161
|
+
/** Adapter selection metadata */
|
|
162
|
+
metadata?: PaymentMetadata;
|
|
163
|
+
/**
|
|
164
|
+
* ERC-8004 agent ID (populated when 'to' was resolved from agentId).
|
|
165
|
+
* Set by AdapterRouter when resolving agent ID to wallet address.
|
|
166
|
+
* Used for reputation reporting after settlement.
|
|
167
|
+
*/
|
|
168
|
+
erc8004AgentId?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Zod schema for UnifiedPayParams with strict validation.
|
|
172
|
+
*/
|
|
173
|
+
export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
174
|
+
to: z.ZodString;
|
|
175
|
+
amount: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
176
|
+
deadline: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
177
|
+
disputeWindow: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
description: z.ZodOptional<z.ZodString>;
|
|
179
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
180
|
+
preferredAdapter: z.ZodOptional<z.ZodString>;
|
|
181
|
+
requiresEscrow: z.ZodOptional<z.ZodBoolean>;
|
|
182
|
+
requiresDispute: z.ZodOptional<z.ZodBoolean>;
|
|
183
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
184
|
+
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
185
|
+
value: z.ZodString;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
188
|
+
value: string;
|
|
189
|
+
}, {
|
|
190
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
191
|
+
value: string;
|
|
192
|
+
}>>;
|
|
193
|
+
paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
preferredAdapter?: string | undefined;
|
|
196
|
+
requiresEscrow?: boolean | undefined;
|
|
197
|
+
requiresDispute?: boolean | undefined;
|
|
198
|
+
identity?: {
|
|
199
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
200
|
+
value: string;
|
|
201
|
+
} | undefined;
|
|
202
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
preferredAdapter?: string | undefined;
|
|
205
|
+
requiresEscrow?: boolean | undefined;
|
|
206
|
+
requiresDispute?: boolean | undefined;
|
|
207
|
+
identity?: {
|
|
208
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
209
|
+
value: string;
|
|
210
|
+
} | undefined;
|
|
211
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
212
|
+
}>>;
|
|
213
|
+
erc8004AgentId: z.ZodOptional<z.ZodString>;
|
|
214
|
+
}, "strip", z.ZodTypeAny, {
|
|
215
|
+
amount: string | number;
|
|
216
|
+
to: string;
|
|
217
|
+
deadline?: string | number | undefined;
|
|
218
|
+
disputeWindow?: number | undefined;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
metadata?: {
|
|
221
|
+
preferredAdapter?: string | undefined;
|
|
222
|
+
requiresEscrow?: boolean | undefined;
|
|
223
|
+
requiresDispute?: boolean | undefined;
|
|
224
|
+
identity?: {
|
|
225
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
226
|
+
value: string;
|
|
227
|
+
} | undefined;
|
|
228
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
229
|
+
} | undefined;
|
|
230
|
+
erc8004AgentId?: string | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
amount: string | number;
|
|
233
|
+
to: string;
|
|
234
|
+
deadline?: string | number | undefined;
|
|
235
|
+
disputeWindow?: number | undefined;
|
|
236
|
+
description?: string | undefined;
|
|
237
|
+
metadata?: {
|
|
238
|
+
preferredAdapter?: string | undefined;
|
|
239
|
+
requiresEscrow?: boolean | undefined;
|
|
240
|
+
requiresDispute?: boolean | undefined;
|
|
241
|
+
identity?: {
|
|
242
|
+
type: "address" | "erc8004" | "did" | "ens";
|
|
243
|
+
value: string;
|
|
244
|
+
} | undefined;
|
|
245
|
+
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
246
|
+
} | undefined;
|
|
247
|
+
erc8004AgentId?: string | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
/**
|
|
250
|
+
* Transaction state after payment initiation.
|
|
251
|
+
*
|
|
252
|
+
* Note: 'COMMITTED' means funds are locked but work hasn't started.
|
|
253
|
+
* 'IN_PROGRESS' means provider has acknowledged and started work.
|
|
254
|
+
*/
|
|
255
|
+
export type InitialTransactionState = 'COMMITTED' | 'IN_PROGRESS';
|
|
256
|
+
/**
|
|
257
|
+
* Unified payment result returned by all adapters.
|
|
258
|
+
*
|
|
259
|
+
* NOTE: success=true means payment INITIATED, not settled.
|
|
260
|
+
* Caller must call releaseEscrow() after delivery verification.
|
|
261
|
+
*/
|
|
262
|
+
export interface UnifiedPayResult {
|
|
263
|
+
/** ACTP transaction ID */
|
|
264
|
+
txId: string;
|
|
265
|
+
/** Escrow ID (for release) - null for non-escrow adapters */
|
|
266
|
+
escrowId: string | null;
|
|
267
|
+
/** Adapter that handled the payment */
|
|
268
|
+
adapter: string;
|
|
269
|
+
/** Current state (COMMITTED, not SETTLED) */
|
|
270
|
+
state: InitialTransactionState;
|
|
271
|
+
/** Whether payment initiation succeeded */
|
|
272
|
+
success: boolean;
|
|
273
|
+
/** Amount locked (formatted) */
|
|
274
|
+
amount: string;
|
|
275
|
+
/** For x402: the HTTP response */
|
|
276
|
+
response?: Response;
|
|
277
|
+
/** Error message if failed */
|
|
278
|
+
error?: string;
|
|
279
|
+
/**
|
|
280
|
+
* IMPORTANT: Payment is NOT complete until you call:
|
|
281
|
+
* await client.release(result.escrowId)
|
|
282
|
+
*
|
|
283
|
+
* Always true for ACTP-compliant adapters.
|
|
284
|
+
*/
|
|
285
|
+
releaseRequired: boolean;
|
|
286
|
+
/** Provider address (normalized to lowercase) */
|
|
287
|
+
provider: string;
|
|
288
|
+
/** Requester address (normalized to lowercase) */
|
|
289
|
+
requester: string;
|
|
290
|
+
/** Deadline as ISO 8601 timestamp */
|
|
291
|
+
deadline: string;
|
|
292
|
+
/**
|
|
293
|
+
* ERC-8004 agent ID (if transaction involved ERC-8004 agent).
|
|
294
|
+
* Use with ReputationReporter.reportSettlement() after release.
|
|
295
|
+
*/
|
|
296
|
+
erc8004AgentId?: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Zod schema for UnifiedPayResult validation.
|
|
300
|
+
*/
|
|
301
|
+
export declare const UnifiedPayResultSchema: z.ZodObject<{
|
|
302
|
+
txId: z.ZodString;
|
|
303
|
+
escrowId: z.ZodNullable<z.ZodString>;
|
|
304
|
+
adapter: z.ZodString;
|
|
305
|
+
state: z.ZodEnum<["COMMITTED", "IN_PROGRESS"]>;
|
|
306
|
+
success: z.ZodBoolean;
|
|
307
|
+
amount: z.ZodString;
|
|
308
|
+
response: z.ZodOptional<z.ZodAny>;
|
|
309
|
+
error: z.ZodOptional<z.ZodString>;
|
|
310
|
+
releaseRequired: z.ZodBoolean;
|
|
311
|
+
provider: z.ZodString;
|
|
312
|
+
requester: z.ZodString;
|
|
313
|
+
deadline: z.ZodString;
|
|
314
|
+
erc8004AgentId: z.ZodOptional<z.ZodString>;
|
|
315
|
+
}, "strip", z.ZodTypeAny, {
|
|
316
|
+
txId: string;
|
|
317
|
+
requester: string;
|
|
318
|
+
provider: string;
|
|
319
|
+
amount: string;
|
|
320
|
+
deadline: string;
|
|
321
|
+
escrowId: string | null;
|
|
322
|
+
adapter: string;
|
|
323
|
+
state: "COMMITTED" | "IN_PROGRESS";
|
|
324
|
+
success: boolean;
|
|
325
|
+
releaseRequired: boolean;
|
|
326
|
+
response?: any;
|
|
327
|
+
error?: string | undefined;
|
|
328
|
+
erc8004AgentId?: string | undefined;
|
|
329
|
+
}, {
|
|
330
|
+
txId: string;
|
|
331
|
+
requester: string;
|
|
332
|
+
provider: string;
|
|
333
|
+
amount: string;
|
|
334
|
+
deadline: string;
|
|
335
|
+
escrowId: string | null;
|
|
336
|
+
adapter: string;
|
|
337
|
+
state: "COMMITTED" | "IN_PROGRESS";
|
|
338
|
+
success: boolean;
|
|
339
|
+
releaseRequired: boolean;
|
|
340
|
+
response?: any;
|
|
341
|
+
error?: string | undefined;
|
|
342
|
+
erc8004AgentId?: string | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
/**
|
|
345
|
+
* Validates UnifiedPayParams at runtime.
|
|
346
|
+
*
|
|
347
|
+
* @param params - Parameters to validate
|
|
348
|
+
* @returns Validated params
|
|
349
|
+
* @throws {z.ZodError} If validation fails
|
|
350
|
+
*/
|
|
351
|
+
export declare function validatePayParams(params: unknown): UnifiedPayParams;
|
|
352
|
+
/**
|
|
353
|
+
* Safe parse for UnifiedPayParams (doesn't throw).
|
|
354
|
+
*
|
|
355
|
+
* @param params - Parameters to validate
|
|
356
|
+
* @returns Result with success flag and data or error
|
|
357
|
+
*/
|
|
358
|
+
export declare function safeValidatePayParams(params: unknown): z.SafeParseReturnType<unknown, UnifiedPayParams>;
|
|
359
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/types/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IAEX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IAEb,kCAAkC;IAClC,UAAU,EAAE,OAAO,CAAC;IAEpB,kDAAkD;IAClD,gBAAgB,EAAE,OAAO,CAAC;IAE1B,iDAAiD;IACjD,gBAAgB,EAAE,OAAO,CAAC;IAE1B,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;;;;OAKG;IACH,cAAc,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAEhD,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAShC,CAAC;AAMH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,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;IAExB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,6CAA6C;IAC7C,KAAK,EAAE,uBAAuB,CAAC;IAE/B,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IAEjB,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IAEjB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAElB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcjC,CAAC;AAMH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAEvG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter types for the ACTP SDK adapter routing system.
|
|
4
|
+
*
|
|
5
|
+
* This module defines types and Zod schemas for:
|
|
6
|
+
* - AdapterMetadata: Capabilities and configuration for each adapter
|
|
7
|
+
* - PaymentMetadata: Request-level hints for adapter selection
|
|
8
|
+
* - UnifiedPayParams: Common payment parameters across adapters
|
|
9
|
+
* - UnifiedPayResult: Common result type for all adapters
|
|
10
|
+
*
|
|
11
|
+
* @module types/adapter
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.safeValidatePayParams = exports.validatePayParams = exports.UnifiedPayResultSchema = exports.UnifiedPayParamsSchema = exports.PaymentMetadataSchema = exports.PaymentIdentitySchema = exports.AdapterMetadataSchema = void 0;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema for AdapterMetadata runtime validation.
|
|
18
|
+
*/
|
|
19
|
+
exports.AdapterMetadataSchema = zod_1.z.object({
|
|
20
|
+
id: zod_1.z.string().min(1),
|
|
21
|
+
name: zod_1.z.string().min(1),
|
|
22
|
+
usesEscrow: zod_1.z.boolean(),
|
|
23
|
+
supportsDisputes: zod_1.z.boolean(),
|
|
24
|
+
requiresIdentity: zod_1.z.boolean(),
|
|
25
|
+
supportedIdentityTypes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
26
|
+
settlementMode: zod_1.z.enum(['explicit', 'timed', 'atomic']),
|
|
27
|
+
priority: zod_1.z.number().int().min(0).max(100),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Zod schema for PaymentIdentity runtime validation.
|
|
31
|
+
*/
|
|
32
|
+
exports.PaymentIdentitySchema = zod_1.z.object({
|
|
33
|
+
type: zod_1.z.enum(['erc8004', 'did', 'ens', 'address']),
|
|
34
|
+
value: zod_1.z.string().min(1),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Zod schema for PaymentMetadata runtime validation.
|
|
38
|
+
*/
|
|
39
|
+
exports.PaymentMetadataSchema = zod_1.z.object({
|
|
40
|
+
preferredAdapter: zod_1.z.string().optional(),
|
|
41
|
+
requiresEscrow: zod_1.z.boolean().optional(),
|
|
42
|
+
requiresDispute: zod_1.z.boolean().optional(),
|
|
43
|
+
identity: exports.PaymentIdentitySchema.optional(),
|
|
44
|
+
paymentMethod: zod_1.z.enum(['x402', 'actp', 'auto']).optional(),
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Minimum dispute window in seconds (1 hour).
|
|
48
|
+
* Ensures requesters have reasonable time to dispute.
|
|
49
|
+
*/
|
|
50
|
+
const MIN_DISPUTE_WINDOW = 3600;
|
|
51
|
+
/**
|
|
52
|
+
* Maximum dispute window in seconds (30 days).
|
|
53
|
+
* Prevents excessively long fund locks.
|
|
54
|
+
*/
|
|
55
|
+
const MAX_DISPUTE_WINDOW = 30 * 24 * 3600;
|
|
56
|
+
/**
|
|
57
|
+
* Zod schema for UnifiedPayParams with strict validation.
|
|
58
|
+
*/
|
|
59
|
+
exports.UnifiedPayParamsSchema = zod_1.z.object({
|
|
60
|
+
to: zod_1.z.string().min(1),
|
|
61
|
+
amount: zod_1.z.union([zod_1.z.string().min(1), zod_1.z.number().positive()]),
|
|
62
|
+
deadline: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
|
|
63
|
+
disputeWindow: zod_1.z
|
|
64
|
+
.number()
|
|
65
|
+
.int()
|
|
66
|
+
.min(MIN_DISPUTE_WINDOW)
|
|
67
|
+
.max(MAX_DISPUTE_WINDOW)
|
|
68
|
+
.optional(),
|
|
69
|
+
description: zod_1.z.string().optional(),
|
|
70
|
+
metadata: exports.PaymentMetadataSchema.optional(),
|
|
71
|
+
erc8004AgentId: zod_1.z.string().optional(),
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Zod schema for UnifiedPayResult validation.
|
|
75
|
+
*/
|
|
76
|
+
exports.UnifiedPayResultSchema = zod_1.z.object({
|
|
77
|
+
txId: zod_1.z.string().min(1),
|
|
78
|
+
escrowId: zod_1.z.string().nullable(),
|
|
79
|
+
adapter: zod_1.z.string().min(1),
|
|
80
|
+
state: zod_1.z.enum(['COMMITTED', 'IN_PROGRESS']),
|
|
81
|
+
success: zod_1.z.boolean(),
|
|
82
|
+
amount: zod_1.z.string().min(1),
|
|
83
|
+
response: zod_1.z.any().optional(),
|
|
84
|
+
error: zod_1.z.string().optional(),
|
|
85
|
+
releaseRequired: zod_1.z.boolean(),
|
|
86
|
+
provider: zod_1.z.string().min(1),
|
|
87
|
+
requester: zod_1.z.string().min(1),
|
|
88
|
+
deadline: zod_1.z.string().min(1),
|
|
89
|
+
erc8004AgentId: zod_1.z.string().optional(),
|
|
90
|
+
});
|
|
91
|
+
// ============================================================================
|
|
92
|
+
// Validation Helpers
|
|
93
|
+
// ============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Validates UnifiedPayParams at runtime.
|
|
96
|
+
*
|
|
97
|
+
* @param params - Parameters to validate
|
|
98
|
+
* @returns Validated params
|
|
99
|
+
* @throws {z.ZodError} If validation fails
|
|
100
|
+
*/
|
|
101
|
+
function validatePayParams(params) {
|
|
102
|
+
return exports.UnifiedPayParamsSchema.parse(params);
|
|
103
|
+
}
|
|
104
|
+
exports.validatePayParams = validatePayParams;
|
|
105
|
+
/**
|
|
106
|
+
* Safe parse for UnifiedPayParams (doesn't throw).
|
|
107
|
+
*
|
|
108
|
+
* @param params - Parameters to validate
|
|
109
|
+
* @returns Result with success flag and data or error
|
|
110
|
+
*/
|
|
111
|
+
function safeValidatePayParams(params) {
|
|
112
|
+
return exports.UnifiedPayParamsSchema.safeParse(params);
|
|
113
|
+
}
|
|
114
|
+
exports.safeValidatePayParams = safeValidatePayParams;
|
|
115
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/types/adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,6BAAwB;AA6CxB;;GAEG;AACU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE;IACvB,gBAAgB,EAAE,OAAC,CAAC,OAAO,EAAE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,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAEH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,MAAe;IAC/C,OAAO,8BAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAFD,8CAEC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAe;IACnD,OAAO,8BAAsB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERC-8004 Trustless Agents - SDK Types
|
|
3
|
+
*
|
|
4
|
+
* Types and constants for ERC-8004 integration.
|
|
5
|
+
*
|
|
6
|
+
* SECURITY NOTES:
|
|
7
|
+
* - Identity Registry is read-only (safe, no gas)
|
|
8
|
+
* - Reputation Registry writes require gas (requester pays)
|
|
9
|
+
* - Replay protection via feedbackHash = keccak256(txId)
|
|
10
|
+
* - ERC-8004 restriction: feedback submitter ≠ agent owner
|
|
11
|
+
*
|
|
12
|
+
* @see https://eips.ethereum.org/EIPS/eip-8004
|
|
13
|
+
* @module types/erc8004
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Networks with ERC-8004 registry deployments.
|
|
17
|
+
*/
|
|
18
|
+
export type ERC8004Network = 'ethereum' | 'base' | 'base-sepolia';
|
|
19
|
+
/**
|
|
20
|
+
* Agent identity resolved from ERC-8004 Identity Registry.
|
|
21
|
+
*/
|
|
22
|
+
export interface ERC8004Agent {
|
|
23
|
+
/** ERC-8004 agent ID (uint256 as string) */
|
|
24
|
+
agentId: string;
|
|
25
|
+
/** Owner address (EOA that controls the NFT) */
|
|
26
|
+
owner: string;
|
|
27
|
+
/** Payment wallet address (checksummed) */
|
|
28
|
+
wallet: string;
|
|
29
|
+
/** Agent URI (IPFS or HTTPS, points to metadata JSON) */
|
|
30
|
+
agentURI: string;
|
|
31
|
+
/** Parsed metadata from agentURI (may be undefined if fetch fails) */
|
|
32
|
+
metadata?: ERC8004AgentMetadata;
|
|
33
|
+
/** Network where agent is registered */
|
|
34
|
+
network: ERC8004Network;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Agent metadata schema from ERC-8004 agentURI.
|
|
38
|
+
*
|
|
39
|
+
* Standard fields defined by ERC-8004, plus arbitrary extensions.
|
|
40
|
+
*/
|
|
41
|
+
export interface ERC8004AgentMetadata {
|
|
42
|
+
/** Human-readable agent name */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Agent description */
|
|
45
|
+
description?: string;
|
|
46
|
+
/** Agent avatar/logo URL */
|
|
47
|
+
image?: string;
|
|
48
|
+
/** Wallet address for receiving payments (overrides owner) */
|
|
49
|
+
paymentAddress?: string;
|
|
50
|
+
/** Alternative field name for payment address */
|
|
51
|
+
wallet?: string;
|
|
52
|
+
/** List of agent capabilities */
|
|
53
|
+
capabilities?: string[];
|
|
54
|
+
/** Service endpoints */
|
|
55
|
+
endpoints?: {
|
|
56
|
+
api?: string;
|
|
57
|
+
webhook?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Allow arbitrary extensions */
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Feedback entry for ERC-8004 Reputation Registry.
|
|
64
|
+
*
|
|
65
|
+
* For ACTP settlements, we use binary values:
|
|
66
|
+
* - value: 1 (success) or -1 (dispute lost)
|
|
67
|
+
* - valueDecimals: 0 (no fractional part)
|
|
68
|
+
*/
|
|
69
|
+
export interface ReputationFeedback {
|
|
70
|
+
/** ERC-8004 agent ID */
|
|
71
|
+
agentId: string;
|
|
72
|
+
/**
|
|
73
|
+
* Feedback value.
|
|
74
|
+
* For ACTP: 1 = successful settlement, -1 = dispute lost
|
|
75
|
+
*/
|
|
76
|
+
value: number;
|
|
77
|
+
/**
|
|
78
|
+
* Decimal precision for value.
|
|
79
|
+
* For ACTP: always 0 (binary)
|
|
80
|
+
*/
|
|
81
|
+
valueDecimals: number;
|
|
82
|
+
/**
|
|
83
|
+
* Primary tag for categorization.
|
|
84
|
+
* ACTP uses: 'actp_settled', 'actp_dispute_won', 'actp_dispute_lost'
|
|
85
|
+
*/
|
|
86
|
+
tag1: string;
|
|
87
|
+
/**
|
|
88
|
+
* Secondary tag for filtering.
|
|
89
|
+
* ACTP uses: capability (e.g., 'code_generation', 'data_analysis')
|
|
90
|
+
*/
|
|
91
|
+
tag2: string;
|
|
92
|
+
/** Service endpoint (optional) */
|
|
93
|
+
endpoint?: string;
|
|
94
|
+
/** Link to detailed feedback (optional, IPFS or HTTPS) */
|
|
95
|
+
feedbackURI?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Hash for replay protection.
|
|
98
|
+
* ACTP uses: keccak256(txId)
|
|
99
|
+
*/
|
|
100
|
+
feedbackHash: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Aggregated reputation summary for an agent.
|
|
104
|
+
*/
|
|
105
|
+
export interface ReputationSummary {
|
|
106
|
+
/** ERC-8004 agent ID */
|
|
107
|
+
agentId: string;
|
|
108
|
+
/** Total feedback count */
|
|
109
|
+
feedbackCount: number;
|
|
110
|
+
/** Count of positive feedback (value > 0) */
|
|
111
|
+
positiveCount: number;
|
|
112
|
+
/** Count of negative feedback (value < 0) */
|
|
113
|
+
negativeCount: number;
|
|
114
|
+
/** Aggregated score (sum of values) */
|
|
115
|
+
score: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* ERC-8004 error codes.
|
|
119
|
+
*/
|
|
120
|
+
export declare enum ERC8004ErrorCode {
|
|
121
|
+
AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
|
|
122
|
+
INVALID_AGENT_ID = "INVALID_AGENT_ID",
|
|
123
|
+
WALLET_NOT_FOUND = "WALLET_NOT_FOUND",
|
|
124
|
+
METADATA_FETCH_FAILED = "METADATA_FETCH_FAILED",
|
|
125
|
+
REPORT_FAILED = "REPORT_FAILED",
|
|
126
|
+
ALREADY_REPORTED = "ALREADY_REPORTED",
|
|
127
|
+
NOT_AUTHORIZED = "NOT_AUTHORIZED",
|
|
128
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
129
|
+
INVALID_NETWORK = "INVALID_NETWORK"
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Custom error for ERC-8004 operations.
|
|
133
|
+
*/
|
|
134
|
+
export declare class ERC8004Error extends Error {
|
|
135
|
+
readonly code: ERC8004ErrorCode;
|
|
136
|
+
readonly agentId?: string | undefined;
|
|
137
|
+
readonly cause?: Error | undefined;
|
|
138
|
+
constructor(message: string, code: ERC8004ErrorCode, agentId?: string | undefined, cause?: Error | undefined);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* ERC-8004 Identity Registry addresses per network.
|
|
142
|
+
*
|
|
143
|
+
* Canonical CREATE2 addresses from: https://github.com/erc-8004/erc-8004-contracts
|
|
144
|
+
* Vanity prefix 0x8004 ensures same address across all EVM chains.
|
|
145
|
+
*/
|
|
146
|
+
export declare const ERC8004_IDENTITY_REGISTRY: Record<ERC8004Network, string>;
|
|
147
|
+
/**
|
|
148
|
+
* ERC-8004 Reputation Registry addresses per network.
|
|
149
|
+
*
|
|
150
|
+
* Canonical CREATE2 addresses from: https://github.com/erc-8004/erc-8004-contracts
|
|
151
|
+
* Vanity prefix 0x8004 ensures same address across all EVM chains.
|
|
152
|
+
*/
|
|
153
|
+
export declare const ERC8004_REPUTATION_REGISTRY: Record<ERC8004Network, string>;
|
|
154
|
+
/**
|
|
155
|
+
* Minimal ABI for ERC-8004 Identity Registry.
|
|
156
|
+
* Only includes view functions needed by ERC8004Bridge.
|
|
157
|
+
*/
|
|
158
|
+
export declare const ERC8004_IDENTITY_ABI: readonly ["function ownerOf(uint256 agentId) view returns (address)", "function getAgentURI(uint256 agentId) view returns (string)", "function balanceOf(address owner) view returns (uint256)", "function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)"];
|
|
159
|
+
/**
|
|
160
|
+
* Minimal ABI for ERC-8004 Reputation Registry.
|
|
161
|
+
* Includes both read and write functions.
|
|
162
|
+
*/
|
|
163
|
+
export declare const ERC8004_REPUTATION_ABI: readonly ["function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash) external", "function revokeLatest(uint256 agentId, uint64 feedbackIndex) external", "function getSummary(uint256 agentId, address[] clientAddresses, string tag1, string tag2) view returns (uint256 count, int256 summaryValue, uint8 summaryValueDecimals)", "function readFeedback(uint256 agentId, uint64 feedbackIndex) view returns (tuple(int128 value, uint8 valueDecimals, string tag1, string tag2, bool isRevoked, uint64 feedbackIndex))"];
|
|
164
|
+
/**
|
|
165
|
+
* Default RPC URLs for each network.
|
|
166
|
+
* Used when no custom RPC is provided.
|
|
167
|
+
*/
|
|
168
|
+
export declare const ERC8004_DEFAULT_RPC: Record<ERC8004Network, string>;
|
|
169
|
+
/**
|
|
170
|
+
* ACTP feedback tags for ERC-8004 Reputation.
|
|
171
|
+
*/
|
|
172
|
+
export declare const ACTP_FEEDBACK_TAGS: {
|
|
173
|
+
/** Successful settlement */
|
|
174
|
+
readonly SETTLED: "actp_settled";
|
|
175
|
+
/** Agent won dispute */
|
|
176
|
+
readonly DISPUTE_WON: "actp_dispute_won";
|
|
177
|
+
/** Agent lost dispute (requester won) */
|
|
178
|
+
readonly DISPUTE_LOST: "actp_dispute_lost";
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Type for ACTP feedback tags.
|
|
182
|
+
*/
|
|
183
|
+
export type ACTPFeedbackTag = (typeof ACTP_FEEDBACK_TAGS)[keyof typeof ACTP_FEEDBACK_TAGS];
|
|
184
|
+
//# sourceMappingURL=erc8004.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc8004.d.ts","sourceRoot":"","sources":["../../src/types/erc8004.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,cAAc,CAAC;AAMlE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAEhB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IAEd,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IAEf,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IAEjB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEhC,wCAAwC;IACxC,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,wBAAwB;IACxB,SAAS,CAAC,EAAE;QACV,GA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