@virtuals-protocol/acp-node 0.3.0-beta.1 → 0.3.0-beta.10

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as viem from 'viem';
2
- import { Address, Chain } from 'viem';
2
+ import { Address, Chain, createPublicClient } from 'viem';
3
3
  import * as _aa_sdk_core from '@aa-sdk/core';
4
4
  import { Address as Address$1, SmartAccountSigner } from '@aa-sdk/core';
5
5
  import { baseSepolia, base } from '@account-kit/infra';
@@ -9,6 +9,7 @@ import * as _aa_sdk_core_dist_types_actions_smartAccount_signMessage from '@aa-s
9
9
  import * as _aa_sdk_core_dist_types_actions_smartAccount_checkGasSponsorshipEligibility from '@aa-sdk/core/dist/types/actions/smartAccount/checkGasSponsorshipEligibility';
10
10
  import * as viem__types_utils_ccip from 'viem/_types/utils/ccip';
11
11
  import * as _account_kit_smart_contracts from '@account-kit/smart-contracts';
12
+ import { ModularAccountV2Client } from '@account-kit/smart-contracts';
12
13
 
13
14
  declare const ACP_ABI: ({
14
15
  inputs: never[];
@@ -176,76 +177,6 @@ declare const ACP_V2_ABI: ({
176
177
  anonymous?: undefined;
177
178
  })[];
178
179
 
179
- declare class AcpContractConfig {
180
- chain: typeof baseSepolia | typeof base;
181
- contractAddress: Address$1;
182
- baseFare: Fare;
183
- alchemyRpcUrl: string;
184
- acpUrl: string;
185
- abi: typeof ACP_ABI | typeof ACP_V2_ABI;
186
- rpcEndpoint?: string | undefined;
187
- constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, rpcEndpoint?: string | undefined);
188
- }
189
- declare const baseSepoliaAcpConfig: AcpContractConfig;
190
- declare const baseSepoliaAcpConfigV2: AcpContractConfig;
191
- declare const baseAcpConfig: AcpContractConfig;
192
- declare const baseAcpConfigV2: AcpContractConfig;
193
-
194
- declare enum MemoType {
195
- MESSAGE = 0,// 0 - Text message
196
- CONTEXT_URL = 1,// 1 - URL for context
197
- IMAGE_URL = 2,// 2 - Image URL
198
- VOICE_URL = 3,// 3 - Voice/audio URL
199
- OBJECT_URL = 4,// 4 - Object/file URL
200
- TXHASH = 5,// 5 - Transaction hash reference
201
- PAYABLE_REQUEST = 6,// 6 - Payment request
202
- PAYABLE_TRANSFER = 7,// 7 - Direct payment transfer
203
- PAYABLE_TRANSFER_ESCROW = 8,// 8 - Escrowed payment transfer
204
- NOTIFICATION = 9,// 9 - Notification
205
- PAYABLE_NOTIFICATION = 10
206
- }
207
- declare enum AcpJobPhases {
208
- REQUEST = 0,
209
- NEGOTIATION = 1,
210
- TRANSACTION = 2,
211
- EVALUATION = 3,
212
- COMPLETED = 4,
213
- REJECTED = 5,
214
- EXPIRED = 6
215
- }
216
- declare enum FeeType {
217
- NO_FEE = 0,
218
- IMMEDIATE_FEE = 1,
219
- DEFERRED_FEE = 2
220
- }
221
- declare abstract class BaseAcpContractClient {
222
- agentWalletAddress: Address;
223
- config: AcpContractConfig;
224
- contractAddress: Address;
225
- chain: Chain;
226
- abi: typeof ACP_ABI | typeof ACP_V2_ABI;
227
- jobCreatedSignature: string;
228
- constructor(agentWalletAddress: Address, config?: AcpContractConfig);
229
- abstract handleOperation(data: `0x${string}`, contractAddress: Address, value?: bigint): Promise<Address>;
230
- abstract getJobId(hash: Address, clientAddress: Address, providerAddress: Address): Promise<number>;
231
- get walletAddress(): `0x${string}`;
232
- createJobWithAccount(accountId: number, providerAddress: Address, evaluatorAddress: Address, budgetBaseUnit: bigint, paymentTokenAddress: Address, expiredAt: Date): Promise<{
233
- txHash: string;
234
- jobId: number;
235
- }>;
236
- createJob(providerAddress: Address, evaluatorAddress: Address, expiredAt: Date, paymentTokenAddress: Address, budgetBaseUnit: bigint, metadata: string): Promise<{
237
- txHash: string;
238
- jobId: number;
239
- }>;
240
- approveAllowance(amountBaseUnit: bigint, paymentTokenAddress?: Address): Promise<`0x${string}`>;
241
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, token?: Address, secured?: boolean): Promise<`0x${string}`>;
242
- createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): Promise<Address>;
243
- signMemo(memoId: number, isApproved: boolean, reason?: string): Promise<`0x${string}`>;
244
- setBudgetWithPaymentToken(jobId: number, budgetBaseUnit: bigint, paymentTokenAddress?: Address): Promise<`0x${string}`>;
245
- updateAccountMetadata(accountId: number, metadata: string): Promise<`0x${string}`>;
246
- wrapEth(amountBaseUnit: bigint): Promise<`0x${string}`>;
247
- }
248
-
249
180
  declare class AcpAccount {
250
181
  contractClient: BaseAcpContractClient;
251
182
  id: number;
@@ -253,7 +184,7 @@ declare class AcpAccount {
253
184
  providerAddress: Address;
254
185
  metadata: Record<string, any>;
255
186
  constructor(contractClient: BaseAcpContractClient, id: number, clientAddress: Address, providerAddress: Address, metadata: Record<string, any>);
256
- updateMetadata(metadata: Record<string, any>): Promise<`0x${string}`>;
187
+ updateMetadata(metadata: Record<string, any>): Promise<OperationPayload>;
257
188
  }
258
189
 
259
190
  declare class AcpMemo {
@@ -271,8 +202,104 @@ declare class AcpMemo {
271
202
  constructor(contractClient: BaseAcpContractClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined);
272
203
  get payloadType(): PayloadType | undefined;
273
204
  getStructuredContent<T>(): GenericPayload<T> | undefined;
274
- create(jobId: number, isSecured?: boolean): Promise<`0x${string}`>;
275
- sign(approved: boolean, reason?: string): Promise<`0x${string}`>;
205
+ create(jobId: number, isSecured?: boolean): Promise<OperationPayload>;
206
+ sign(approved: boolean, reason?: string): Promise<{
207
+ userOpHash: Address;
208
+ txnHash: Address;
209
+ }>;
210
+ }
211
+
212
+ declare enum PriceType {
213
+ FIXED = "fixed",
214
+ PERCENTAGE = "percentage"
215
+ }
216
+ declare class AcpJobOffering {
217
+ private readonly acpClient;
218
+ private readonly acpContractClient;
219
+ providerAddress: Address;
220
+ name: string;
221
+ price: number;
222
+ priceType: PriceType;
223
+ requirement?: (Object | string) | undefined;
224
+ private ajv;
225
+ constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType?: PriceType, requirement?: (Object | string) | undefined);
226
+ initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
227
+ }
228
+
229
+ declare class AcpJob {
230
+ private acpClient;
231
+ id: number;
232
+ clientAddress: Address;
233
+ providerAddress: Address;
234
+ evaluatorAddress: Address;
235
+ price: number;
236
+ priceTokenAddress: Address;
237
+ memos: AcpMemo[];
238
+ phase: AcpJobPhases;
239
+ context: Record<string, any>;
240
+ contractAddress: Address;
241
+ netPayableAmount?: number | undefined;
242
+ name: string | undefined;
243
+ requirement: Record<string, any> | string | undefined;
244
+ priceType: PriceType;
245
+ priceValue: number;
246
+ constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, netPayableAmount?: number | undefined);
247
+ get acpContractClient(): BaseAcpContractClient;
248
+ get config(): AcpContractConfig;
249
+ get baseFare(): Fare;
250
+ get deliverable(): string | undefined;
251
+ get rejectionReason(): string | undefined;
252
+ get providerAgent(): Promise<AcpAgent | undefined>;
253
+ get clientAgent(): Promise<AcpAgent | undefined>;
254
+ get evaluatorAgent(): Promise<AcpAgent | undefined>;
255
+ get account(): Promise<AcpAccount | null>;
256
+ get latestMemo(): AcpMemo | undefined;
257
+ createRequirement(content: string): Promise<{
258
+ userOpHash: Address;
259
+ txnHash: Address;
260
+ }>;
261
+ createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, amount: FareAmountBase, recipient: Address, expiredAt?: Date): Promise<{
262
+ userOpHash: Address;
263
+ txnHash: Address;
264
+ }>;
265
+ payAndAcceptRequirement(reason?: string): Promise<{
266
+ userOpHash: Address;
267
+ txnHash: Address;
268
+ }>;
269
+ respond(accept: boolean, reason?: string): Promise<{
270
+ userOpHash: Address;
271
+ txnHash: Address;
272
+ }>;
273
+ accept(reason?: string): Promise<{
274
+ userOpHash: Address;
275
+ txnHash: Address;
276
+ }>;
277
+ reject(reason?: string): Promise<{
278
+ userOpHash: Address;
279
+ txnHash: Address;
280
+ }>;
281
+ rejectPayable(reason: string | undefined, amount: FareAmountBase, expiredAt?: Date): Promise<{
282
+ userOpHash: Address;
283
+ txnHash: Address;
284
+ }>;
285
+ deliver(deliverable: DeliverablePayload): Promise<{
286
+ userOpHash: Address;
287
+ txnHash: Address;
288
+ }>;
289
+ deliverPayable(deliverable: DeliverablePayload, amount: FareAmountBase, expiredAt?: Date): Promise<{
290
+ userOpHash: Address;
291
+ txnHash: Address;
292
+ }>;
293
+ evaluate(accept: boolean, reason?: string): Promise<void>;
294
+ createNotification(content: string): Promise<{
295
+ userOpHash: Address;
296
+ txnHash: Address;
297
+ }>;
298
+ createPayableNotification(content: string, amount: FareAmountBase, expiredAt?: Date): Promise<{
299
+ userOpHash: Address;
300
+ txnHash: Address;
301
+ }>;
302
+ private performX402Payment;
276
303
  }
277
304
 
278
305
  type DeliverablePayload = string | Record<string, unknown>;
@@ -305,6 +332,10 @@ declare enum AcpOnlineStatus {
305
332
  ONLINE = "online",
306
333
  OFFLINE = "offline"
307
334
  }
335
+ interface IAcpJobX402PaymentDetails {
336
+ isX402: boolean;
337
+ isBudgetReceived: boolean;
338
+ }
308
339
  interface IAcpClientOptions {
309
340
  acpContractClient: BaseAcpContractClient | BaseAcpContractClient[];
310
341
  onNewTask?: (job: AcpJob, memoToSign?: AcpMemo) => void;
@@ -326,7 +357,10 @@ type AcpAgent = {
326
357
  twitterHandle: string;
327
358
  jobs: {
328
359
  name: string;
329
- price: number;
360
+ priceV2: {
361
+ type: PriceType;
362
+ value: number;
363
+ };
330
364
  requirement?: Object | string;
331
365
  deliverable?: Object | string;
332
366
  }[];
@@ -401,144 +435,170 @@ type ClosePositionPayload = {
401
435
  positionId: number;
402
436
  amount: number;
403
437
  };
404
- type PositionFulfilledPayload = {
405
- symbol: string;
406
- amount: number;
407
- contractAddress: string;
408
- type: "TP" | "SL" | "CLOSE";
409
- pnl: number;
410
- entryPrice: number;
411
- exitPrice: number;
412
- };
413
- type UnfulfilledPositionPayload = {
414
- symbol: string;
415
- amount: number;
416
- contractAddress: string;
417
- type: "ERROR" | "PARTIAL";
418
- reason?: string;
419
- };
420
438
  type RequestClosePositionPayload = {
421
439
  positionId: number;
422
440
  };
423
-
424
- declare class AcpJob {
425
- private acpClient;
441
+ type X402Config = {
442
+ url: string;
443
+ };
444
+ type X402PayableRequirements = {
445
+ x402Version: number;
446
+ error: string;
447
+ accepts: X402Requirement[];
448
+ };
449
+ type X402Requirement = {
450
+ scheme: string;
451
+ network: string;
452
+ maxAmountRequired: string;
453
+ resource: string;
454
+ description: string;
455
+ mimeType: string;
456
+ payTo: Address;
457
+ maxTimeoutSeconds: number;
458
+ asset: Address;
459
+ extra: {
460
+ name: string;
461
+ version: string;
462
+ };
463
+ outputSchema: any;
464
+ };
465
+ type X402PayableRequest = {
466
+ to: Address;
467
+ value: number;
468
+ maxTimeoutSeconds: number;
469
+ asset: Address;
470
+ };
471
+ type X402Payment = {
472
+ encodedPayment: string;
473
+ signature: string;
474
+ message: {
475
+ from: Address;
476
+ to: Address;
477
+ value: string;
478
+ validAfter: string;
479
+ validBefore: string;
480
+ nonce: string;
481
+ };
482
+ };
483
+ type OffChainJob = {
426
484
  id: number;
485
+ documentId: string;
486
+ txHash: Address;
487
+ clientId: number;
488
+ providerId: number;
489
+ budget: number;
490
+ createdAt: string;
491
+ updatedAt: string;
492
+ publishedAt: string;
493
+ locale: string | null;
427
494
  clientAddress: Address;
428
495
  providerAddress: Address;
429
- evaluatorAddress: Address;
430
- price: number;
431
- priceTokenAddress: Address;
432
- memos: AcpMemo[];
496
+ evaluators: Address[];
497
+ budgetTxHash: Address | null;
433
498
  phase: AcpJobPhases;
434
- context: Record<string, any>;
499
+ agentIdPair: string;
500
+ onChainJobId: string;
501
+ summary: string;
502
+ userOpHash: Address | null;
503
+ amountClaimed: number;
504
+ context: Record<string, any> | null;
505
+ expiry: string;
506
+ refundRetryTimes: number;
507
+ additionalFees: number;
508
+ budgetTokenAddress: Address;
509
+ budgetUSD: number;
510
+ amountClaimedUSD: number | null;
511
+ additionalFeesUSD: number | null;
435
512
  contractAddress: Address;
436
- name: string | undefined;
437
- requirement: Record<string, any> | string | undefined;
438
- constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address);
439
- get acpContractClient(): BaseAcpContractClient;
440
- get config(): AcpContractConfig;
441
- get baseFare(): Fare;
442
- get deliverable(): string | undefined;
443
- get rejectionReason(): string | undefined;
444
- get providerAgent(): Promise<AcpAgent | undefined>;
445
- get clientAgent(): Promise<AcpAgent | undefined>;
446
- get evaluatorAgent(): Promise<AcpAgent | undefined>;
447
- get account(): Promise<AcpAccount | null>;
448
- get latestMemo(): AcpMemo | undefined;
449
- createRequirement(content: string): Promise<`0x${string}`>;
450
- createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, amount: FareAmountBase, recipient: Address, expiredAt?: Date): Promise<`0x${string}`>;
451
- payAndAcceptRequirement(reason?: string): Promise<`0x${string}`>;
452
- respond(accept: boolean, reason?: string): Promise<`0x${string}`>;
453
- accept(reason?: string): Promise<`0x${string}`>;
454
- reject(reason?: string): Promise<`0x${string}`>;
455
- deliver(deliverable: DeliverablePayload): Promise<`0x${string}`>;
456
- deliverPayable(deliverable: DeliverablePayload, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
457
- evaluate(accept: boolean, reason?: string): Promise<void>;
458
- pay(reason?: string): Promise<`0x${string}`>;
459
- createNotification(content: string): Promise<`0x${string}`>;
460
- createPayableNotification(content: string, amount: FareAmountBase, expiredAt?: Date): Promise<`0x${string}`>;
461
- /**
462
- * @deprecated The method should not be used
463
- */
464
- openPosition(payload: OpenPositionPayload[], feeAmount: number, expiredAt?: Date, // 3 minutes
465
- walletAddress?: Address): Promise<`0x${string}`>;
466
- /**
467
- * @deprecated The method should not be used
468
- */
469
- swapToken(payload: SwapTokenPayload, decimals: number, feeAmount: number, walletAddress?: Address): Promise<`0x${string}`>;
470
- /**
471
- * @deprecated The method should not be used
472
- */
473
- responseSwapToken(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
474
- /**
475
- * @deprecated The method should not be used
476
- */
477
- transferFunds<T>(payload: GenericPayload<T>, fareAmount: FareAmountBase, walletAddress?: Address, expiredAt?: Date): Promise<`0x${string}`>;
478
- /**
479
- * @deprecated The method should not be used
480
- */
481
- responseOpenPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
482
- /**
483
- * @deprecated The method should not be used
484
- */
485
- closePartialPosition(payload: ClosePositionPayload, expireAt?: Date): Promise<`0x${string}`>;
486
- /**
487
- * @deprecated The method should not be used
488
- */
489
- responseClosePartialPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
490
- /**
491
- * @deprecated The method should not be used
492
- */
493
- requestClosePosition(payload: RequestClosePositionPayload): Promise<`0x${string}`>;
494
- /**
495
- * @deprecated The method should not be used
496
- */
497
- responseRequestClosePosition(memoId: number, accept: boolean, payload: ClosePositionPayload, reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
498
- /**
499
- * @deprecated The method should not be used
500
- */
501
- confirmClosePosition(memoId: number, accept: boolean, reason?: string): Promise<void>;
502
- /**
503
- * @deprecated The method should not be used
504
- */
505
- positionFulfilled(payload: PositionFulfilledPayload, expiredAt?: Date): Promise<`0x${string}`>;
506
- /**
507
- * @deprecated The method should not be used
508
- */
509
- unfulfilledPosition(payload: UnfulfilledPositionPayload, expiredAt?: Date): Promise<`0x${string}`>;
510
- /**
511
- * @deprecated The method should not be used
512
- */
513
- responseUnfulfilledPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
514
- /**
515
- * @deprecated The method should not be used
516
- */
517
- responsePositionFulfilled(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
518
- /**
519
- * @deprecated The method should not be used
520
- */
521
- closeJob(message?: string): Promise<`0x${string}`>;
522
- /**
523
- * @deprecated The method should not be used
524
- */
525
- responseCloseJob(memoId: number, accept: boolean, fulfilledPositions: PositionFulfilledPayload[], reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
526
- /**
527
- * @deprecated The method should not be used
528
- */
529
- confirmJobClosure(memoId: number, accept: boolean, reason?: string): Promise<void>;
513
+ accountId: number | null;
514
+ x402Nonce: string;
515
+ };
516
+ type X402PaymentResponse = {
517
+ isPaymentRequired: boolean;
518
+ data: X402PayableRequirements;
519
+ };
520
+
521
+ declare class AcpContractConfig {
522
+ chain: typeof baseSepolia | typeof base;
523
+ contractAddress: Address$1;
524
+ baseFare: Fare;
525
+ alchemyRpcUrl: string;
526
+ acpUrl: string;
527
+ abi: typeof ACP_ABI | typeof ACP_V2_ABI;
528
+ rpcEndpoint?: string | undefined;
529
+ x402Config?: X402Config | undefined;
530
+ constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, rpcEndpoint?: string | undefined, x402Config?: X402Config | undefined);
530
531
  }
532
+ declare const baseSepoliaAcpConfig: AcpContractConfig;
533
+ declare const baseSepoliaAcpConfigV2: AcpContractConfig;
534
+ declare const baseAcpConfig: AcpContractConfig;
535
+ declare const baseAcpX402Config: AcpContractConfig;
536
+ declare const baseAcpConfigV2: AcpContractConfig;
537
+ declare const baseAcpX402ConfigV2: AcpContractConfig;
531
538
 
532
- declare class AcpJobOffering {
533
- private readonly acpClient;
534
- private readonly acpContractClient;
535
- providerAddress: Address;
536
- name: string;
537
- price: number;
538
- requirement?: (Object | string) | undefined;
539
- private ajv;
540
- constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, requirement?: (Object | string) | undefined);
541
- initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
539
+ declare enum MemoType {
540
+ MESSAGE = 0,// 0 - Text message
541
+ CONTEXT_URL = 1,// 1 - URL for context
542
+ IMAGE_URL = 2,// 2 - Image URL
543
+ VOICE_URL = 3,// 3 - Voice/audio URL
544
+ OBJECT_URL = 4,// 4 - Object/file URL
545
+ TXHASH = 5,// 5 - Transaction hash reference
546
+ PAYABLE_REQUEST = 6,// 6 - Payment request
547
+ PAYABLE_TRANSFER = 7,// 7 - Direct payment transfer
548
+ PAYABLE_TRANSFER_ESCROW = 8,// 8 - Escrowed payment transfer
549
+ NOTIFICATION = 9,// 9 - Notification
550
+ PAYABLE_NOTIFICATION = 10
551
+ }
552
+ declare enum AcpJobPhases {
553
+ REQUEST = 0,
554
+ NEGOTIATION = 1,
555
+ TRANSACTION = 2,
556
+ EVALUATION = 3,
557
+ COMPLETED = 4,
558
+ REJECTED = 5,
559
+ EXPIRED = 6
560
+ }
561
+ declare enum FeeType {
562
+ NO_FEE = 0,
563
+ IMMEDIATE_FEE = 1,
564
+ DEFERRED_FEE = 2,
565
+ PERCENTAGE_FEE = 3
566
+ }
567
+ interface OperationPayload {
568
+ data: `0x${string}`;
569
+ contractAddress: Address;
570
+ value?: bigint;
571
+ }
572
+ declare abstract class BaseAcpContractClient {
573
+ agentWalletAddress: Address;
574
+ config: AcpContractConfig;
575
+ contractAddress: Address;
576
+ chain: Chain;
577
+ abi: typeof ACP_ABI | typeof ACP_V2_ABI;
578
+ jobCreatedSignature: string;
579
+ publicClient: ReturnType<typeof createPublicClient>;
580
+ constructor(agentWalletAddress: Address, config?: AcpContractConfig);
581
+ abstract handleOperation(operations: OperationPayload[]): Promise<{
582
+ userOpHash: Address;
583
+ txnHash: Address;
584
+ }>;
585
+ abstract getJobId(createJobUserOpHash: Address, clientAddress: Address, providerAddress: Address): Promise<number>;
586
+ get walletAddress(): `0x${string}`;
587
+ createJobWithAccount(accountId: number, evaluatorAddress: Address, budgetBaseUnit: bigint, paymentTokenAddress: Address, expiredAt: Date, isX402Job?: boolean): OperationPayload;
588
+ createJob(providerAddress: Address, evaluatorAddress: Address, expiredAt: Date, paymentTokenAddress: Address, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
589
+ approveAllowance(amountBaseUnit: bigint, paymentTokenAddress?: Address): OperationPayload;
590
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, token?: Address, secured?: boolean): OperationPayload;
591
+ createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): OperationPayload;
592
+ signMemo(memoId: number, isApproved: boolean, reason?: string): OperationPayload;
593
+ setBudgetWithPaymentToken(jobId: number, budgetBaseUnit: bigint, paymentTokenAddress?: Address): OperationPayload | undefined;
594
+ updateAccountMetadata(accountId: number, metadata: string): OperationPayload;
595
+ wrapEth(amountBaseUnit: bigint): OperationPayload;
596
+ getX402PaymentDetails(jobId: number): Promise<IAcpJobX402PaymentDetails>;
597
+ abstract updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
598
+ abstract generateX402Payment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
599
+ abstract performX402Request(url: string, version: string, budget?: string, signature?: string): Promise<X402PaymentResponse>;
600
+ submitTransferWithAuthorization(from: Address, to: Address, value: bigint, validAfter: bigint, validBefore: bigint, nonce: string, signature: string): Promise<OperationPayload[]>;
601
+ abstract getAcpVersion(): string;
542
602
  }
543
603
 
544
604
  interface IAcpBrowseAgentsOptions {
@@ -574,19 +634,15 @@ declare class AcpClient {
574
634
  minsFromLastOnline: number;
575
635
  isOnline: boolean;
576
636
  } | undefined;
637
+ resource: {
638
+ name: string;
639
+ description: string;
640
+ url: string;
641
+ parameters?: Object;
642
+ id: number;
643
+ }[];
577
644
  }[]>;
578
645
  initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
579
- createMemo(jobId: number, content: string, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
580
- createPayableMemo(jobId: number, content: string, amount: FareAmountBase, recipient: Address, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date): Promise<`0x${string}`>;
581
- respondJob(jobId: number, memoId: number, accept: boolean, content?: string, reason?: string): Promise<`0x${string}` | undefined>;
582
- payJob(jobId: number, amountBaseUnit: bigint, memoId: number, reason?: string): Promise<`0x${string}`>;
583
- requestFunds<T>(jobId: number, transferFareAmount: FareAmountBase, recipient: Address, feeFareAmount: FareAmountBase, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
584
- responseFundsRequest(memoId: number, accept: boolean, amountBaseUnit: bigint, reason?: string): Promise<`0x${string}`>;
585
- transferFunds<T>(jobId: number, transferFareAmount: FareAmountBase, recipient: Address, feeFareAmount: FareAmountBase, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
586
- sendMessage<T>(jobId: number, message: GenericPayload<T>, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
587
- responseFundsTransfer(memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
588
- rejectJob(jobId: number, reason?: string): Promise<`0x${string}`>;
589
- deliverJob(jobId: number, deliverable: DeliverablePayload): Promise<`0x${string}`>;
590
646
  getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
591
647
  getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
592
648
  getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
@@ -598,13 +654,28 @@ declare class AcpClient {
598
654
  getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
599
655
  }
600
656
 
657
+ declare class AcpX402 {
658
+ private config;
659
+ private sessionKeyClient;
660
+ private publicClient;
661
+ constructor(config: AcpContractConfig, sessionKeyClient: ModularAccountV2Client, publicClient: ReturnType<typeof createPublicClient>);
662
+ signUpdateJobNonceMessage(jobId: number, nonce: string): Promise<`0x${string}`>;
663
+ updateJobNonce(jobId: number, nonce: string): Promise<OffChainJob>;
664
+ generatePayment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
665
+ performRequest(url: string, version: string, budget?: string, signature?: string): Promise<{
666
+ isPaymentRequired: boolean;
667
+ data: any;
668
+ }>;
669
+ }
670
+
601
671
  declare class AcpContractClient extends BaseAcpContractClient {
602
672
  protected MAX_RETRIES: number;
603
673
  protected PRIORITY_FEE_MULTIPLIER: number;
604
674
  protected MAX_FEE_PER_GAS: number;
605
675
  protected MAX_PRIORITY_FEE_PER_GAS: number;
606
676
  private _sessionKeyClient;
607
- constructor(agentWalletAddress: Address$1, config?: AcpContractConfig);
677
+ private _acpX402;
678
+ constructor(agentWalletAddress: Address$1, config?: AcpContractConfig, maxRetries?: number);
608
679
  static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClient>;
609
680
  init(privateKey: Address$1, sessionEntityKeyId: number): Promise<void>;
610
681
  getRandomNonce(bits?: number): bigint;
@@ -822,6 +893,10 @@ declare class AcpContractClient extends BaseAcpContractClient {
822
893
  Method: "eth_sendRawTransaction";
823
894
  Parameters: [signedTransaction: viem.Hex];
824
895
  ReturnType: viem.Hash;
896
+ }, {
897
+ Method: "eth_sendRawTransactionSync";
898
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
899
+ ReturnType: viem.RpcTransactionReceipt;
825
900
  }, {
826
901
  Method: "eth_simulateV1";
827
902
  Parameters: [{
@@ -7908,6 +7983,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
7908
7983
  }, (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "fees" | "gas" | "nonce" | "blobVersionedHashes" | "chainId" | "type") extends infer T_13 ? T_13 extends (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "fees" | "gas" | "nonce" | "blobVersionedHashes" | "chainId" | "type") ? T_13 extends "fees" ? "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" : T_13 : never : never> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K]; } : never>;
7909
7984
  readContract: <const abi extends viem.Abi | readonly unknown[], functionName extends viem.ContractFunctionName<abi, "pure" | "view">, const args extends viem.ContractFunctionArgs<abi, "pure" | "view", functionName>>(args: viem.ReadContractParameters<abi, functionName, args>) => Promise<viem.ReadContractReturnType<abi, functionName, args>>;
7910
7985
  sendRawTransaction: (args: viem.SendRawTransactionParameters) => Promise<viem.SendRawTransactionReturnType>;
7986
+ sendRawTransactionSync: (args: viem.SendRawTransactionSyncParameters) => Promise<viem.TransactionReceipt>;
7911
7987
  simulate: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
7912
7988
  simulateBlocks: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
7913
7989
  simulateCalls: <const calls extends readonly unknown[]>(args: viem.SimulateCallsParameters<calls>) => Promise<viem.SimulateCallsReturnType<calls>>;
@@ -8137,6 +8213,10 @@ declare class AcpContractClient extends BaseAcpContractClient {
8137
8213
  Method: "eth_sendRawTransaction";
8138
8214
  Parameters: [signedTransaction: viem.Hex];
8139
8215
  ReturnType: viem.Hash;
8216
+ }, {
8217
+ Method: "eth_sendRawTransactionSync";
8218
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
8219
+ ReturnType: viem.RpcTransactionReceipt;
8140
8220
  }, {
8141
8221
  Method: "eth_simulateV1";
8142
8222
  Parameters: [{
@@ -8588,6 +8668,10 @@ declare class AcpContractClient extends BaseAcpContractClient {
8588
8668
  Method: "eth_sendRawTransaction";
8589
8669
  Parameters: [signedTransaction: viem.Hex];
8590
8670
  ReturnType: viem.Hash;
8671
+ }, {
8672
+ Method: "eth_sendRawTransactionSync";
8673
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
8674
+ ReturnType: viem.RpcTransactionReceipt;
8591
8675
  }, {
8592
8676
  Method: "eth_simulateV1";
8593
8677
  Parameters: [{
@@ -8842,19 +8926,22 @@ declare class AcpContractClient extends BaseAcpContractClient {
8842
8926
  getAddress: () => Address$1;
8843
8927
  } & _aa_sdk_core.BundlerActions & viem.PublicActions>;
8844
8928
  };
8929
+ get acpX402(): AcpX402;
8845
8930
  private calculateGasFees;
8846
- handleOperation(data: `0x${string}`, contractAddress?: Address$1, value?: bigint): Promise<`0x${string}`>;
8847
- getJobId(hash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
8848
- createJob(providerAddress: Address$1, evaluatorAddress: Address$1, expireAt: Date, paymentTokenAddress: Address$1, budgetBaseUnit: bigint, metadata: string): Promise<{
8849
- txHash: string;
8850
- jobId: number;
8851
- }>;
8852
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address$1, secured?: boolean): Promise<`0x${string}`>;
8853
- createJobWithAccount(accountId: number, providerAddress: Address$1, evaluatorAddress: Address$1, budgetBaseUnit: bigint, paymentTokenAddress: Address$1, expiredAt: Date): Promise<{
8854
- txHash: string;
8855
- jobId: number;
8931
+ handleOperation(operations: OperationPayload[]): Promise<{
8932
+ userOpHash: Address$1;
8933
+ txnHash: Address$1;
8856
8934
  }>;
8857
- updateAccountMetadata(accountId: number, metadata: string): Promise<Address$1>;
8935
+ getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
8936
+ createJob(providerAddress: Address$1, evaluatorAddress: Address$1, expireAt: Date, paymentTokenAddress: Address$1, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
8937
+ setBudgetWithPaymentToken(jobId: number, budgetBaseUnit: bigint, paymentTokenAddress?: Address$1): OperationPayload;
8938
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address$1, secured?: boolean): OperationPayload;
8939
+ createJobWithAccount(accountId: number, evaluatorAddress: Address$1, budgetBaseUnit: bigint, paymentTokenAddress: Address$1, expiredAt: Date, isX402Job?: boolean): OperationPayload;
8940
+ updateAccountMetadata(accountId: number, metadata: string): OperationPayload;
8941
+ updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
8942
+ generateX402Payment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
8943
+ performX402Request(url: string, version: string, budget?: string, signature?: string): Promise<X402PaymentResponse>;
8944
+ getAcpVersion(): string;
8858
8945
  }
8859
8946
 
8860
8947
  declare function preparePayload(payload: string | object): string;
@@ -8872,7 +8959,8 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8872
8959
  private MAX_FEE_PER_GAS;
8873
8960
  private MAX_PRIORITY_FEE_PER_GAS;
8874
8961
  private _sessionKeyClient;
8875
- constructor(jobManagerAddress: Address$1, memoManagerAddress: Address$1, accountManagerAddress: Address$1, agentWalletAddress: Address$1, config?: AcpContractConfig);
8962
+ private _acpX402;
8963
+ constructor(jobManagerAddress: Address$1, memoManagerAddress: Address$1, accountManagerAddress: Address$1, agentWalletAddress: Address$1, config?: AcpContractConfig, maxRetries?: number);
8876
8964
  static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClientV2>;
8877
8965
  init(privateKey: Address$1, sessionEntityKeyId: number): Promise<void>;
8878
8966
  getRandomNonce(bits?: number): bigint;
@@ -9090,6 +9178,10 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
9090
9178
  Method: "eth_sendRawTransaction";
9091
9179
  Parameters: [signedTransaction: viem.Hex];
9092
9180
  ReturnType: viem.Hash;
9181
+ }, {
9182
+ Method: "eth_sendRawTransactionSync";
9183
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
9184
+ ReturnType: viem.RpcTransactionReceipt;
9093
9185
  }, {
9094
9186
  Method: "eth_simulateV1";
9095
9187
  Parameters: [{
@@ -16176,6 +16268,7 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
16176
16268
  }, (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "fees" | "gas" | "nonce" | "blobVersionedHashes" | "chainId" | "type") extends infer T_13 ? T_13 extends (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "fees" | "gas" | "nonce" | "blobVersionedHashes" | "chainId" | "type") ? T_13 extends "fees" ? "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" : T_13 : never : never> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K]; } : never>;
16177
16269
  readContract: <const abi extends viem.Abi | readonly unknown[], functionName extends viem.ContractFunctionName<abi, "pure" | "view">, const args extends viem.ContractFunctionArgs<abi, "pure" | "view", functionName>>(args: viem.ReadContractParameters<abi, functionName, args>) => Promise<viem.ReadContractReturnType<abi, functionName, args>>;
16178
16270
  sendRawTransaction: (args: viem.SendRawTransactionParameters) => Promise<viem.SendRawTransactionReturnType>;
16271
+ sendRawTransactionSync: (args: viem.SendRawTransactionSyncParameters) => Promise<viem.TransactionReceipt>;
16179
16272
  simulate: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
16180
16273
  simulateBlocks: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
16181
16274
  simulateCalls: <const calls extends readonly unknown[]>(args: viem.SimulateCallsParameters<calls>) => Promise<viem.SimulateCallsReturnType<calls>>;
@@ -16405,6 +16498,10 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
16405
16498
  Method: "eth_sendRawTransaction";
16406
16499
  Parameters: [signedTransaction: viem.Hex];
16407
16500
  ReturnType: viem.Hash;
16501
+ }, {
16502
+ Method: "eth_sendRawTransactionSync";
16503
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
16504
+ ReturnType: viem.RpcTransactionReceipt;
16408
16505
  }, {
16409
16506
  Method: "eth_simulateV1";
16410
16507
  Parameters: [{
@@ -16856,6 +16953,10 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
16856
16953
  Method: "eth_sendRawTransaction";
16857
16954
  Parameters: [signedTransaction: viem.Hex];
16858
16955
  ReturnType: viem.Hash;
16956
+ }, {
16957
+ Method: "eth_sendRawTransactionSync";
16958
+ Parameters: [signedTransaction: viem.Hex] | [signedTransaction: viem.Hex, timeout: viem.Hex];
16959
+ ReturnType: viem.RpcTransactionReceipt;
16859
16960
  }, {
16860
16961
  Method: "eth_simulateV1";
16861
16962
  Parameters: [{
@@ -17110,9 +17211,18 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
17110
17211
  getAddress: () => Address$1;
17111
17212
  } & _aa_sdk_core.BundlerActions & viem.PublicActions>;
17112
17213
  };
17214
+ get acpX402(): AcpX402;
17113
17215
  private calculateGasFees;
17114
- handleOperation(data: `0x${string}`, contractAddress?: Address$1, value?: bigint): Promise<`0x${string}`>;
17115
- getJobId(hash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
17216
+ handleOperation(operations: OperationPayload[]): Promise<{
17217
+ userOpHash: Address$1;
17218
+ txnHash: Address$1;
17219
+ }>;
17220
+ getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
17221
+ updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
17222
+ generateX402Payment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
17223
+ performX402Request(url: string, version: string, budget?: string, signature?: string): Promise<X402PaymentResponse>;
17224
+ getX402PaymentDetails(jobId: number): Promise<IAcpJobX402PaymentDetails>;
17225
+ getAcpVersion(): string;
17116
17226
  }
17117
17227
 
17118
- export { ACP_ABI, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type ClosePositionPayload, type DeliverablePayload, Fare, FareAmount, FareBigInt, type FundResponsePayload, type IDeliverable, MemoType, type OpenPositionPayload, PayloadType, PositionDirection, type RequestClosePositionPayload, type ResponseSwapTokenPayload, type SwapTokenPayload, baseAcpConfig, baseAcpConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };
17228
+ export { ACP_ABI, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type ClosePositionPayload, type DeliverablePayload, Fare, FareAmount, FareBigInt, type FundResponsePayload, type IDeliverable, MemoType, type OpenPositionPayload, PayloadType, PositionDirection, type RequestClosePositionPayload, type ResponseSwapTokenPayload, type SwapTokenPayload, baseAcpConfig, baseAcpConfigV2, baseAcpX402Config, baseAcpX402ConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };