uvd-x402-sdk 2.17.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/backend/index.d.mts +216 -3
- package/dist/backend/index.d.ts +216 -3
- package/dist/backend/index.js +386 -0
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +380 -1
- package/dist/backend/index.mjs.map +1 -1
- package/dist/{index-BE5cH7oS.d.mts → index-B49n9gXd.d.mts} +1 -1
- package/dist/{index-BE5cH7oS.d.ts → index-B49n9gXd.d.ts} +1 -1
- package/dist/{index-DDrvK4em.d.ts → index-BNDjK-t2.d.ts} +2 -2
- package/dist/{index-BDLgm-Sg.d.mts → index-Df7wrPNp.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +200 -200
- package/src/backend/index.ts +3384 -2825
package/dist/adapters/index.d.ts
CHANGED
package/dist/backend/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as X402Header, K as X402Version } from '../index-B49n9gXd.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* uvd-x402-sdk - Backend Utilities
|
|
@@ -1047,7 +1047,7 @@ declare const ERC8004_CONTRACTS: Record<string, {
|
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Network type for ERC-8004 operations
|
|
1049
1049
|
*/
|
|
1050
|
-
type Erc8004Network = 'ethereum' | 'ethereum-sepolia';
|
|
1050
|
+
type Erc8004Network = 'ethereum' | 'ethereum-sepolia' | 'base-mainnet';
|
|
1051
1051
|
/**
|
|
1052
1052
|
* Proof of payment returned when settling with ERC-8004 extension
|
|
1053
1053
|
*/
|
|
@@ -1422,5 +1422,218 @@ declare function buildErc8004PaymentRequirements(options: PaymentRequirementsOpt
|
|
|
1422
1422
|
};
|
|
1423
1423
|
};
|
|
1424
1424
|
};
|
|
1425
|
+
/**
|
|
1426
|
+
* PAYMENT_INFO_TYPEHASH used for nonce computation.
|
|
1427
|
+
* Must match the on-chain AuthCaptureEscrow contract.
|
|
1428
|
+
*/
|
|
1429
|
+
declare const PAYMENT_INFO_TYPEHASH = "0xae68ac7ce30c86ece8196b61a7c486d8f0061f575037fbd34e7fe4e2820c6591";
|
|
1430
|
+
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1431
|
+
/**
|
|
1432
|
+
* Contract deposit limit (enforced by PaymentOperator condition).
|
|
1433
|
+
* As of 2026-02-03, commerce-payments contracts enforce $100 max per deposit.
|
|
1434
|
+
*/
|
|
1435
|
+
declare const DEPOSIT_LIMIT_USDC = "100000000";
|
|
1436
|
+
/**
|
|
1437
|
+
* Base Mainnet contract addresses for the Advanced Escrow system.
|
|
1438
|
+
*/
|
|
1439
|
+
declare const BASE_MAINNET_CONTRACTS: {
|
|
1440
|
+
operator: string;
|
|
1441
|
+
escrow: string;
|
|
1442
|
+
tokenCollector: string;
|
|
1443
|
+
usdc: string;
|
|
1444
|
+
};
|
|
1445
|
+
/**
|
|
1446
|
+
* Task tiers determine timing parameters for escrow operations.
|
|
1447
|
+
*/
|
|
1448
|
+
type AdvancedEscrowTaskTier = 'micro' | 'standard' | 'premium' | 'enterprise';
|
|
1449
|
+
/**
|
|
1450
|
+
* Timing configuration per task tier (in seconds).
|
|
1451
|
+
*/
|
|
1452
|
+
declare const TIER_TIMINGS: Record<AdvancedEscrowTaskTier, {
|
|
1453
|
+
pre: number;
|
|
1454
|
+
auth: number;
|
|
1455
|
+
refund: number;
|
|
1456
|
+
}>;
|
|
1457
|
+
/**
|
|
1458
|
+
* PaymentInfo struct matching the on-chain PaymentOperator contract.
|
|
1459
|
+
*/
|
|
1460
|
+
interface AdvancedPaymentInfo {
|
|
1461
|
+
operator: string;
|
|
1462
|
+
receiver: string;
|
|
1463
|
+
token: string;
|
|
1464
|
+
maxAmount: string;
|
|
1465
|
+
preApprovalExpiry: number;
|
|
1466
|
+
authorizationExpiry: number;
|
|
1467
|
+
refundExpiry: number;
|
|
1468
|
+
minFeeBps: number;
|
|
1469
|
+
maxFeeBps: number;
|
|
1470
|
+
feeReceiver: string;
|
|
1471
|
+
salt: string;
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Result of an AUTHORIZE operation.
|
|
1475
|
+
*/
|
|
1476
|
+
interface AdvancedAuthorizationResult {
|
|
1477
|
+
success: boolean;
|
|
1478
|
+
transactionHash?: string;
|
|
1479
|
+
paymentInfo?: AdvancedPaymentInfo;
|
|
1480
|
+
salt?: string;
|
|
1481
|
+
error?: string;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Result of an on-chain transaction (release, refund, charge).
|
|
1485
|
+
*/
|
|
1486
|
+
interface AdvancedTransactionResult {
|
|
1487
|
+
success: boolean;
|
|
1488
|
+
transactionHash?: string;
|
|
1489
|
+
gasUsed?: number;
|
|
1490
|
+
error?: string;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Contract addresses configuration for AdvancedEscrowClient.
|
|
1494
|
+
*/
|
|
1495
|
+
interface AdvancedEscrowContracts {
|
|
1496
|
+
operator: string;
|
|
1497
|
+
escrow: string;
|
|
1498
|
+
tokenCollector: string;
|
|
1499
|
+
usdc: string;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Configuration options for AdvancedEscrowClient.
|
|
1503
|
+
*/
|
|
1504
|
+
interface AdvancedEscrowClientOptions {
|
|
1505
|
+
/** Facilitator URL for AUTHORIZE operations */
|
|
1506
|
+
facilitatorUrl?: string;
|
|
1507
|
+
/** JSON-RPC URL for on-chain operations */
|
|
1508
|
+
rpcUrl?: string;
|
|
1509
|
+
/** Chain ID (default: 8453 for Base Mainnet) */
|
|
1510
|
+
chainId?: number;
|
|
1511
|
+
/** Contract addresses (default: Base Mainnet) */
|
|
1512
|
+
contracts?: AdvancedEscrowContracts;
|
|
1513
|
+
/** Gas limit for transactions (default: 300000) */
|
|
1514
|
+
gasLimit?: number;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Minimal PaymentOperator ABI for the 4 on-chain functions.
|
|
1518
|
+
* (AUTHORIZE goes through the facilitator, not directly on-chain)
|
|
1519
|
+
*/
|
|
1520
|
+
declare const OPERATOR_ABI: string[];
|
|
1521
|
+
/**
|
|
1522
|
+
* AdvancedEscrowClient provides the 5 Advanced Escrow flows via the
|
|
1523
|
+
* PaymentOperator contract on Base Mainnet.
|
|
1524
|
+
*
|
|
1525
|
+
* @example
|
|
1526
|
+
* ```typescript
|
|
1527
|
+
* import { ethers } from 'ethers';
|
|
1528
|
+
* import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
|
|
1529
|
+
*
|
|
1530
|
+
* const client = new AdvancedEscrowClient(signer, {
|
|
1531
|
+
* facilitatorUrl: 'https://facilitator.ultravioletadao.xyz',
|
|
1532
|
+
* rpcUrl: 'https://mainnet.base.org',
|
|
1533
|
+
* });
|
|
1534
|
+
*
|
|
1535
|
+
* // Lock funds in escrow
|
|
1536
|
+
* const pi = client.buildPaymentInfo('0xWorker...', '5000000', 'standard');
|
|
1537
|
+
* const auth = await client.authorize(pi);
|
|
1538
|
+
*
|
|
1539
|
+
* // After work is done, release to worker
|
|
1540
|
+
* const tx = await client.release(pi);
|
|
1541
|
+
*
|
|
1542
|
+
* // Or cancel and refund
|
|
1543
|
+
* const refund = await client.refundInEscrow(pi);
|
|
1544
|
+
* ```
|
|
1545
|
+
*/
|
|
1546
|
+
declare class AdvancedEscrowClient {
|
|
1547
|
+
private facilitatorUrl;
|
|
1548
|
+
private chainId;
|
|
1549
|
+
private gasLimit;
|
|
1550
|
+
private contracts;
|
|
1551
|
+
private signer;
|
|
1552
|
+
private payerAddress;
|
|
1553
|
+
constructor(signer: any, options?: AdvancedEscrowClientOptions);
|
|
1554
|
+
/**
|
|
1555
|
+
* Initialize the client (resolves signer address).
|
|
1556
|
+
* Call this before using any methods.
|
|
1557
|
+
*/
|
|
1558
|
+
init(): Promise<void>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Build a PaymentInfo struct with appropriate timing for the task tier.
|
|
1561
|
+
*
|
|
1562
|
+
* @param receiver - Worker's wallet address
|
|
1563
|
+
* @param amount - Amount in token atomic units (e.g., '5000000' for $5 USDC)
|
|
1564
|
+
* @param tier - Task tier determines timing parameters
|
|
1565
|
+
* @param salt - Random salt (auto-generated if not provided)
|
|
1566
|
+
*/
|
|
1567
|
+
buildPaymentInfo(receiver: string, amount: string, tier?: AdvancedEscrowTaskTier, salt?: string): AdvancedPaymentInfo;
|
|
1568
|
+
/**
|
|
1569
|
+
* Compute the correct nonce (with PAYMENT_INFO_TYPEHASH).
|
|
1570
|
+
* Matches the on-chain AuthCaptureEscrow nonce derivation.
|
|
1571
|
+
*/
|
|
1572
|
+
private computeNonce;
|
|
1573
|
+
/**
|
|
1574
|
+
* Sign ReceiveWithAuthorization for ERC-3009.
|
|
1575
|
+
*/
|
|
1576
|
+
private signErc3009;
|
|
1577
|
+
/**
|
|
1578
|
+
* Build the on-chain PaymentInfo tuple for contract calls.
|
|
1579
|
+
*/
|
|
1580
|
+
private buildTuple;
|
|
1581
|
+
/**
|
|
1582
|
+
* AUTHORIZE: Lock funds in escrow via the facilitator.
|
|
1583
|
+
*
|
|
1584
|
+
* Sends an ERC-3009 ReceiveWithAuthorization to the facilitator,
|
|
1585
|
+
* which calls PaymentOperator.authorize() on-chain.
|
|
1586
|
+
*/
|
|
1587
|
+
authorize(paymentInfo: AdvancedPaymentInfo): Promise<AdvancedAuthorizationResult>;
|
|
1588
|
+
/**
|
|
1589
|
+
* RELEASE: Capture escrowed funds to receiver (worker gets paid).
|
|
1590
|
+
*
|
|
1591
|
+
* Calls PaymentOperator.release() -> escrow.capture()
|
|
1592
|
+
*
|
|
1593
|
+
* @param paymentInfo - PaymentInfo from the authorize step
|
|
1594
|
+
* @param amount - Amount to release (defaults to maxAmount)
|
|
1595
|
+
*/
|
|
1596
|
+
release(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1597
|
+
/**
|
|
1598
|
+
* REFUND IN ESCROW: Return escrowed funds to payer (cancel task).
|
|
1599
|
+
*
|
|
1600
|
+
* Calls PaymentOperator.refundInEscrow() -> escrow.partialVoid()
|
|
1601
|
+
*
|
|
1602
|
+
* @param paymentInfo - PaymentInfo from the authorize step
|
|
1603
|
+
* @param amount - Amount to refund (defaults to maxAmount)
|
|
1604
|
+
*/
|
|
1605
|
+
refundInEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1606
|
+
/**
|
|
1607
|
+
* CHARGE: Direct instant payment (no escrow hold).
|
|
1608
|
+
*
|
|
1609
|
+
* Calls PaymentOperator.charge() -> escrow.charge()
|
|
1610
|
+
* Funds go directly from payer to receiver.
|
|
1611
|
+
*
|
|
1612
|
+
* @param paymentInfo - PaymentInfo with receiver and amount
|
|
1613
|
+
* @param amount - Amount to charge (defaults to maxAmount)
|
|
1614
|
+
*/
|
|
1615
|
+
charge(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1616
|
+
/**
|
|
1617
|
+
* REFUND POST ESCROW: Dispute refund after funds were released.
|
|
1618
|
+
*
|
|
1619
|
+
* Calls PaymentOperator.refundPostEscrow() -> escrow.refund()
|
|
1620
|
+
*
|
|
1621
|
+
* WARNING: NOT FUNCTIONAL IN PRODUCTION (as of 2026-02-03).
|
|
1622
|
+
* The protocol team has not implemented the required tokenCollector
|
|
1623
|
+
* contract. This call will fail on-chain.
|
|
1624
|
+
*
|
|
1625
|
+
* For dispute resolution, use refundInEscrow() instead: keep funds
|
|
1626
|
+
* in escrow and refund before releasing. This guarantees funds are
|
|
1627
|
+
* available and under arbiter control.
|
|
1628
|
+
*
|
|
1629
|
+
* Kept for future use when tokenCollector is implemented.
|
|
1630
|
+
*
|
|
1631
|
+
* @param paymentInfo - PaymentInfo from the original authorization
|
|
1632
|
+
* @param amount - Amount to refund (defaults to maxAmount)
|
|
1633
|
+
* @param tokenCollector - Address of token collector for refund sourcing
|
|
1634
|
+
* @param collectorData - Data for the token collector
|
|
1635
|
+
*/
|
|
1636
|
+
refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
|
|
1637
|
+
}
|
|
1425
1638
|
|
|
1426
|
-
export { type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
|
1639
|
+
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as X402Header, K as X402Version } from '../index-B49n9gXd.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* uvd-x402-sdk - Backend Utilities
|
|
@@ -1047,7 +1047,7 @@ declare const ERC8004_CONTRACTS: Record<string, {
|
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Network type for ERC-8004 operations
|
|
1049
1049
|
*/
|
|
1050
|
-
type Erc8004Network = 'ethereum' | 'ethereum-sepolia';
|
|
1050
|
+
type Erc8004Network = 'ethereum' | 'ethereum-sepolia' | 'base-mainnet';
|
|
1051
1051
|
/**
|
|
1052
1052
|
* Proof of payment returned when settling with ERC-8004 extension
|
|
1053
1053
|
*/
|
|
@@ -1422,5 +1422,218 @@ declare function buildErc8004PaymentRequirements(options: PaymentRequirementsOpt
|
|
|
1422
1422
|
};
|
|
1423
1423
|
};
|
|
1424
1424
|
};
|
|
1425
|
+
/**
|
|
1426
|
+
* PAYMENT_INFO_TYPEHASH used for nonce computation.
|
|
1427
|
+
* Must match the on-chain AuthCaptureEscrow contract.
|
|
1428
|
+
*/
|
|
1429
|
+
declare const PAYMENT_INFO_TYPEHASH = "0xae68ac7ce30c86ece8196b61a7c486d8f0061f575037fbd34e7fe4e2820c6591";
|
|
1430
|
+
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1431
|
+
/**
|
|
1432
|
+
* Contract deposit limit (enforced by PaymentOperator condition).
|
|
1433
|
+
* As of 2026-02-03, commerce-payments contracts enforce $100 max per deposit.
|
|
1434
|
+
*/
|
|
1435
|
+
declare const DEPOSIT_LIMIT_USDC = "100000000";
|
|
1436
|
+
/**
|
|
1437
|
+
* Base Mainnet contract addresses for the Advanced Escrow system.
|
|
1438
|
+
*/
|
|
1439
|
+
declare const BASE_MAINNET_CONTRACTS: {
|
|
1440
|
+
operator: string;
|
|
1441
|
+
escrow: string;
|
|
1442
|
+
tokenCollector: string;
|
|
1443
|
+
usdc: string;
|
|
1444
|
+
};
|
|
1445
|
+
/**
|
|
1446
|
+
* Task tiers determine timing parameters for escrow operations.
|
|
1447
|
+
*/
|
|
1448
|
+
type AdvancedEscrowTaskTier = 'micro' | 'standard' | 'premium' | 'enterprise';
|
|
1449
|
+
/**
|
|
1450
|
+
* Timing configuration per task tier (in seconds).
|
|
1451
|
+
*/
|
|
1452
|
+
declare const TIER_TIMINGS: Record<AdvancedEscrowTaskTier, {
|
|
1453
|
+
pre: number;
|
|
1454
|
+
auth: number;
|
|
1455
|
+
refund: number;
|
|
1456
|
+
}>;
|
|
1457
|
+
/**
|
|
1458
|
+
* PaymentInfo struct matching the on-chain PaymentOperator contract.
|
|
1459
|
+
*/
|
|
1460
|
+
interface AdvancedPaymentInfo {
|
|
1461
|
+
operator: string;
|
|
1462
|
+
receiver: string;
|
|
1463
|
+
token: string;
|
|
1464
|
+
maxAmount: string;
|
|
1465
|
+
preApprovalExpiry: number;
|
|
1466
|
+
authorizationExpiry: number;
|
|
1467
|
+
refundExpiry: number;
|
|
1468
|
+
minFeeBps: number;
|
|
1469
|
+
maxFeeBps: number;
|
|
1470
|
+
feeReceiver: string;
|
|
1471
|
+
salt: string;
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Result of an AUTHORIZE operation.
|
|
1475
|
+
*/
|
|
1476
|
+
interface AdvancedAuthorizationResult {
|
|
1477
|
+
success: boolean;
|
|
1478
|
+
transactionHash?: string;
|
|
1479
|
+
paymentInfo?: AdvancedPaymentInfo;
|
|
1480
|
+
salt?: string;
|
|
1481
|
+
error?: string;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Result of an on-chain transaction (release, refund, charge).
|
|
1485
|
+
*/
|
|
1486
|
+
interface AdvancedTransactionResult {
|
|
1487
|
+
success: boolean;
|
|
1488
|
+
transactionHash?: string;
|
|
1489
|
+
gasUsed?: number;
|
|
1490
|
+
error?: string;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Contract addresses configuration for AdvancedEscrowClient.
|
|
1494
|
+
*/
|
|
1495
|
+
interface AdvancedEscrowContracts {
|
|
1496
|
+
operator: string;
|
|
1497
|
+
escrow: string;
|
|
1498
|
+
tokenCollector: string;
|
|
1499
|
+
usdc: string;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Configuration options for AdvancedEscrowClient.
|
|
1503
|
+
*/
|
|
1504
|
+
interface AdvancedEscrowClientOptions {
|
|
1505
|
+
/** Facilitator URL for AUTHORIZE operations */
|
|
1506
|
+
facilitatorUrl?: string;
|
|
1507
|
+
/** JSON-RPC URL for on-chain operations */
|
|
1508
|
+
rpcUrl?: string;
|
|
1509
|
+
/** Chain ID (default: 8453 for Base Mainnet) */
|
|
1510
|
+
chainId?: number;
|
|
1511
|
+
/** Contract addresses (default: Base Mainnet) */
|
|
1512
|
+
contracts?: AdvancedEscrowContracts;
|
|
1513
|
+
/** Gas limit for transactions (default: 300000) */
|
|
1514
|
+
gasLimit?: number;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Minimal PaymentOperator ABI for the 4 on-chain functions.
|
|
1518
|
+
* (AUTHORIZE goes through the facilitator, not directly on-chain)
|
|
1519
|
+
*/
|
|
1520
|
+
declare const OPERATOR_ABI: string[];
|
|
1521
|
+
/**
|
|
1522
|
+
* AdvancedEscrowClient provides the 5 Advanced Escrow flows via the
|
|
1523
|
+
* PaymentOperator contract on Base Mainnet.
|
|
1524
|
+
*
|
|
1525
|
+
* @example
|
|
1526
|
+
* ```typescript
|
|
1527
|
+
* import { ethers } from 'ethers';
|
|
1528
|
+
* import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
|
|
1529
|
+
*
|
|
1530
|
+
* const client = new AdvancedEscrowClient(signer, {
|
|
1531
|
+
* facilitatorUrl: 'https://facilitator.ultravioletadao.xyz',
|
|
1532
|
+
* rpcUrl: 'https://mainnet.base.org',
|
|
1533
|
+
* });
|
|
1534
|
+
*
|
|
1535
|
+
* // Lock funds in escrow
|
|
1536
|
+
* const pi = client.buildPaymentInfo('0xWorker...', '5000000', 'standard');
|
|
1537
|
+
* const auth = await client.authorize(pi);
|
|
1538
|
+
*
|
|
1539
|
+
* // After work is done, release to worker
|
|
1540
|
+
* const tx = await client.release(pi);
|
|
1541
|
+
*
|
|
1542
|
+
* // Or cancel and refund
|
|
1543
|
+
* const refund = await client.refundInEscrow(pi);
|
|
1544
|
+
* ```
|
|
1545
|
+
*/
|
|
1546
|
+
declare class AdvancedEscrowClient {
|
|
1547
|
+
private facilitatorUrl;
|
|
1548
|
+
private chainId;
|
|
1549
|
+
private gasLimit;
|
|
1550
|
+
private contracts;
|
|
1551
|
+
private signer;
|
|
1552
|
+
private payerAddress;
|
|
1553
|
+
constructor(signer: any, options?: AdvancedEscrowClientOptions);
|
|
1554
|
+
/**
|
|
1555
|
+
* Initialize the client (resolves signer address).
|
|
1556
|
+
* Call this before using any methods.
|
|
1557
|
+
*/
|
|
1558
|
+
init(): Promise<void>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Build a PaymentInfo struct with appropriate timing for the task tier.
|
|
1561
|
+
*
|
|
1562
|
+
* @param receiver - Worker's wallet address
|
|
1563
|
+
* @param amount - Amount in token atomic units (e.g., '5000000' for $5 USDC)
|
|
1564
|
+
* @param tier - Task tier determines timing parameters
|
|
1565
|
+
* @param salt - Random salt (auto-generated if not provided)
|
|
1566
|
+
*/
|
|
1567
|
+
buildPaymentInfo(receiver: string, amount: string, tier?: AdvancedEscrowTaskTier, salt?: string): AdvancedPaymentInfo;
|
|
1568
|
+
/**
|
|
1569
|
+
* Compute the correct nonce (with PAYMENT_INFO_TYPEHASH).
|
|
1570
|
+
* Matches the on-chain AuthCaptureEscrow nonce derivation.
|
|
1571
|
+
*/
|
|
1572
|
+
private computeNonce;
|
|
1573
|
+
/**
|
|
1574
|
+
* Sign ReceiveWithAuthorization for ERC-3009.
|
|
1575
|
+
*/
|
|
1576
|
+
private signErc3009;
|
|
1577
|
+
/**
|
|
1578
|
+
* Build the on-chain PaymentInfo tuple for contract calls.
|
|
1579
|
+
*/
|
|
1580
|
+
private buildTuple;
|
|
1581
|
+
/**
|
|
1582
|
+
* AUTHORIZE: Lock funds in escrow via the facilitator.
|
|
1583
|
+
*
|
|
1584
|
+
* Sends an ERC-3009 ReceiveWithAuthorization to the facilitator,
|
|
1585
|
+
* which calls PaymentOperator.authorize() on-chain.
|
|
1586
|
+
*/
|
|
1587
|
+
authorize(paymentInfo: AdvancedPaymentInfo): Promise<AdvancedAuthorizationResult>;
|
|
1588
|
+
/**
|
|
1589
|
+
* RELEASE: Capture escrowed funds to receiver (worker gets paid).
|
|
1590
|
+
*
|
|
1591
|
+
* Calls PaymentOperator.release() -> escrow.capture()
|
|
1592
|
+
*
|
|
1593
|
+
* @param paymentInfo - PaymentInfo from the authorize step
|
|
1594
|
+
* @param amount - Amount to release (defaults to maxAmount)
|
|
1595
|
+
*/
|
|
1596
|
+
release(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1597
|
+
/**
|
|
1598
|
+
* REFUND IN ESCROW: Return escrowed funds to payer (cancel task).
|
|
1599
|
+
*
|
|
1600
|
+
* Calls PaymentOperator.refundInEscrow() -> escrow.partialVoid()
|
|
1601
|
+
*
|
|
1602
|
+
* @param paymentInfo - PaymentInfo from the authorize step
|
|
1603
|
+
* @param amount - Amount to refund (defaults to maxAmount)
|
|
1604
|
+
*/
|
|
1605
|
+
refundInEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1606
|
+
/**
|
|
1607
|
+
* CHARGE: Direct instant payment (no escrow hold).
|
|
1608
|
+
*
|
|
1609
|
+
* Calls PaymentOperator.charge() -> escrow.charge()
|
|
1610
|
+
* Funds go directly from payer to receiver.
|
|
1611
|
+
*
|
|
1612
|
+
* @param paymentInfo - PaymentInfo with receiver and amount
|
|
1613
|
+
* @param amount - Amount to charge (defaults to maxAmount)
|
|
1614
|
+
*/
|
|
1615
|
+
charge(paymentInfo: AdvancedPaymentInfo, amount?: string): Promise<AdvancedTransactionResult>;
|
|
1616
|
+
/**
|
|
1617
|
+
* REFUND POST ESCROW: Dispute refund after funds were released.
|
|
1618
|
+
*
|
|
1619
|
+
* Calls PaymentOperator.refundPostEscrow() -> escrow.refund()
|
|
1620
|
+
*
|
|
1621
|
+
* WARNING: NOT FUNCTIONAL IN PRODUCTION (as of 2026-02-03).
|
|
1622
|
+
* The protocol team has not implemented the required tokenCollector
|
|
1623
|
+
* contract. This call will fail on-chain.
|
|
1624
|
+
*
|
|
1625
|
+
* For dispute resolution, use refundInEscrow() instead: keep funds
|
|
1626
|
+
* in escrow and refund before releasing. This guarantees funds are
|
|
1627
|
+
* available and under arbiter control.
|
|
1628
|
+
*
|
|
1629
|
+
* Kept for future use when tokenCollector is implemented.
|
|
1630
|
+
*
|
|
1631
|
+
* @param paymentInfo - PaymentInfo from the original authorization
|
|
1632
|
+
* @param amount - Amount to refund (defaults to maxAmount)
|
|
1633
|
+
* @param tokenCollector - Address of token collector for refund sourcing
|
|
1634
|
+
* @param collectorData - Data for the token collector
|
|
1635
|
+
*/
|
|
1636
|
+
refundPostEscrow(paymentInfo: AdvancedPaymentInfo, amount?: string, tokenCollector?: string, collectorData?: string): Promise<AdvancedTransactionResult>;
|
|
1637
|
+
}
|
|
1425
1638
|
|
|
1426
|
-
export { type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|
|
1639
|
+
export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, BASE_MAINNET_CONTRACTS, type BazaarCategory, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarNetwork, type BazaarRegisterOptions, type BazaarResource, type BazaarToken, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, Erc8004Client, type Erc8004ClientOptions, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, OPERATOR_ABI, PAYMENT_INFO_TYPEHASH, type PaymentRequirements, type PaymentRequirementsOptions, type ProofOfPayment, type RefundRequest, type RefundStatus, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type SettleRequest, type SettleResponse, type SettleResponseWithProof, TIER_TIMINGS, type VerifyRequest, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildVerifyRequest, canRefundEscrow, canReleaseEscrow, create402Response, createPaymentMiddleware, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, isEscrowExpired, parsePaymentHeader };
|