uvd-x402-sdk 2.98.0 → 2.99.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/README.md +1 -1
- package/dist/backend/index.d.mts +1 -1
- package/dist/backend/index.d.ts +1 -1
- package/dist/backend/index.js +217 -4
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +211 -5
- package/dist/backend/index.mjs.map +1 -1
- package/dist/{index-BUlo1dYN.d.ts → index-BiL4seGs.d.ts} +112 -3
- package/dist/{index-Dy7eJ6hX.d.mts → index-SaqboHsK.d.mts} +112 -3
- package/dist/index.d.mts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +306 -6
- package/src/escrow-preauth.arc-vector.json +101 -0
- package/src/escrow-preauth.ts +45 -4
- package/src/fixtures/arc-escrow-d.rpc.json +553 -0
- package/src/fixtures/escrow-operator-snapshot.json +1254 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -1493,7 +1493,7 @@ const state = await escrow.getEscrowState({
|
|
|
1493
1493
|
|
|
1494
1494
|
Full escrow lifecycle management for EVM chains. Supports both `ethers.Signer` and `SigningWalletAdapter` (EnvKey, OWS) for signing.
|
|
1495
1495
|
|
|
1496
|
-
Supported on 10 EVM networks: Base, Base Sepolia, Ethereum, Ethereum Sepolia, Polygon, Arbitrum, Optimism, Celo, Monad, Avalanche.
|
|
1496
|
+
Supported on 10 EVM networks: Base, Base Sepolia, Ethereum, Ethereum Sepolia, Polygon, Arbitrum, Optimism, Celo, Monad, Avalanche. Since 2.99.0 also on Arc and Arc Testnet, on the x402r canonical escrow: there `release` sends `capture` and `refundInEscrow` sends `void`, which only returns the whole capturable amount. See [Escrow on Arc](docs/networks/arc.md#escrow-on-arc-2990).
|
|
1497
1497
|
|
|
1498
1498
|
### With Private Key (ethers.Signer)
|
|
1499
1499
|
|
package/dist/backend/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../wallet-w7BnImDG.mjs';
|
|
2
2
|
export { a as FacilitatorReceipt, F as FetchReceiptResult, P as PaymentState, b as PurchaseContext, c as RECEIPT_ISSUER, R as ReceiptFetchOptions, d as ReceiptKeys, e as canonicalReceiptJson, f as createPurchaseContext, g as fetchWithReceipt, h as getFacilitatorReceipt, m as mergeHeaderList, i as mergePaymentResponseHeaders, p as parseFacilitatorReceipt, j as paymentResponseHeaders, k as purchaseContextHeader, r as receiptCommitment, l as receiptFromErrorBody, n as receiptFromResponse, v as validatePurchaseContext, o as verifyFacilitatorReceipt } from '../receipts-D0zg-8uK.mjs';
|
|
3
3
|
import '../index-BsKsZzP3.mjs';
|
|
4
|
-
export { A as AMBIGUOUS_LEASE_REASONS, a as AUTHORIZATION_ALREADY_SETTLED, b as AUTHORIZATION_IN_FLIGHT, c as AdmittedAuthorizationCode, ap as AdvancedAuthorizationResult, aq as AdvancedEscrowClient, ar as AdvancedEscrowClientOptions, as as AdvancedEscrowContracts, at as AdvancedEscrowTaskTier, au as AdvancedPaymentInfo, av as AdvancedTransactionResult, aw as AgentId, ax as AgentIdentity, ay as AgentRegistration, az as AgentRegistrationFile, aA as AgentService, aB as AtomStats, aC as BASE_MAINNET_CONTRACTS, aD as BazaarClient, aE as BazaarClientOptions, aF as BazaarDiscoverOptions, aG as BazaarDiscoverResponse, aH as BazaarRegisterOptions, aI as BazaarResource, aJ as CreateEscrowOptions, D as DEFAULT_FACILITATOR_RETRIES, d as DEFAULT_RETRY_AFTER_SECONDS, aK as DEPOSIT_LIMIT_USDC, aL as DiscoveryAccepts, aM as DiscoveryCuration, aN as DiscoveryHealth, aO as DiscoveryHealthStatus, aP as DiscoveryListOptions, aQ as DiscoveryPagination, aR as DiscoveryRegisterOptions, aS as DiscoveryResource, aT as DiscoveryResponse, aU as DiscoverySource, aV as DiscoveryStats, aW as DiscoveryTier, aX as Dispute, aY as DisputeOutcome, aZ as ERC8004_CONTRACTS, a_ as ERC8004_EXTENSION_ID, a$ as ESCROW_CONTRACTS, b0 as
|
|
4
|
+
export { A as AMBIGUOUS_LEASE_REASONS, a as AUTHORIZATION_ALREADY_SETTLED, b as AUTHORIZATION_IN_FLIGHT, c as AdmittedAuthorizationCode, ap as AdvancedAuthorizationResult, aq as AdvancedEscrowClient, ar as AdvancedEscrowClientOptions, as as AdvancedEscrowContracts, at as AdvancedEscrowTaskTier, au as AdvancedPaymentInfo, av as AdvancedTransactionResult, aw as AgentId, ax as AgentIdentity, ay as AgentRegistration, az as AgentRegistrationFile, aA as AgentService, aB as AtomStats, aC as BASE_MAINNET_CONTRACTS, aD as BazaarClient, aE as BazaarClientOptions, aF as BazaarDiscoverOptions, aG as BazaarDiscoverResponse, aH as BazaarRegisterOptions, aI as BazaarResource, aJ as CreateEscrowOptions, D as DEFAULT_FACILITATOR_RETRIES, d as DEFAULT_RETRY_AFTER_SECONDS, aK as DEPOSIT_LIMIT_USDC, aL as DiscoveryAccepts, aM as DiscoveryCuration, aN as DiscoveryHealth, aO as DiscoveryHealthStatus, aP as DiscoveryListOptions, aQ as DiscoveryPagination, aR as DiscoveryRegisterOptions, aS as DiscoveryResource, aT as DiscoveryResponse, aU as DiscoverySource, aV as DiscoveryStats, aW as DiscoveryTier, aX as Dispute, aY as DisputeOutcome, aZ as ERC8004_CONTRACTS, a_ as ERC8004_EXTENSION_ID, a$ as ESCROW_CONTRACTS, b0 as ESCROW_NOTHING_TO_VOID, b1 as ESCROW_OPERATOR_GENERATION, b2 as ESCROW_OPERATOR_NOT_DEPLOYED, b3 as ESCROW_TIMEOUT_MS, b4 as ESCROW_UNSUPPORTED_ON_GENERATION, b5 as ESCROW_VOID_AMOUNT_MISMATCH, b6 as Erc8004Client, b7 as Erc8004ClientOptions, b8 as Erc8004LookupError, b9 as Erc8004Network, ba as EscrowClient, bb as EscrowClientOptions, bc as EscrowOperatorGeneration, bd as EscrowPayment, be as EscrowStateResponse, bf as EscrowStatus, F as FacilitatorCallOptions, e as FacilitatorClient, f as FacilitatorClientOptions, g as FacilitatorErrorInfo, h as FacilitatorFailureFields, i as FacilitatorFetchOptions, bg as FeedbackEntry, bh as FeedbackParams, bi as FeedbackRequest, bj as FeedbackResponse, bk as HEALTH_FILTERS, H as HonoMiddlewareOptions, I as IDEMPOTENCY_KEY_HEADER, j as IDEMPOTENT_REPLAYED_HEADER, bl as IdentityByOwnerResponse, bm as IdentityMetadataResponse, bn as IdentityTotalSupplyResponse, bo as LifecycleAuthOptions, M as MAX_RETRY_AFTER_SECONDS, bp as MAX_SEARCH_LEN, bq as MetadataEntryParam, br as OPERATOR_ABI, bs as OPERATOR_ABI_CREATE3, bt as OPERATOR_ABI_V3, bu as PAYMENT_INFO_TYPEHASH, P as ParsedFacilitatorErrorBody, v as PaymentAcceptance, w as PaymentConflictResponse, x as PaymentMiddlewareOptions, y as PaymentPayloadV2, bv as PaymentRequirementResolver, bw as PaymentRequirements, bx as PaymentRequirementsOptions, z as PaymentRequirementsV2, by as PrepareRelayFeedbackRequest, bz as PrepareRelayFeedbackResponse, bA as PrepareRelayResponseRequest, bB as PrepareSolanaFeedbackRequest, bC as PrepareSolanaFeedbackResponse, bD as ProofOfPayment, R as RECEIPT_REQUEST_CONFLICT, bE as RELAYED_FEEDBACK_NETWORKS, C as REPLAYABLE_LEASE_REASONS, bF as RefundRequest, bG as RefundStatus, bH as RegisterAgentRequest, bI as RegisterAgentResponse, bJ as RegisterJobResponse, bK as RegisterJobStatus, bL as RegistrationPendingError, bM as RelayAuthorizationParams, bN as ReputationResponse, bO as ReputationSummary, bP as RequestRefundOptions, E as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, bQ as SOLANA_FEEDBACK_NETWORKS, bR as SettleRequest, G as SettleRequestV2, J as SettleResponse, bS as SettleResponseWithProof, bT as SubmitRelayFeedbackRequest, bU as SubmitRelayResponseRequest, bV as SubmitSolanaFeedbackRequest, bW as TIER_FILTERS, bX as TIER_TIMINGS, bY as USDC_DOMAIN_NAME, bZ as UnavailableBody, b_ as UnavailableResponse, V as VerifiedPaymentState, b$ as VerifyRequest, K as VerifyRequestV2, N as VerifyResponse, W as WRITER_LEASE_REASONS, Q as WriterLeaseReason, X as X402_CORS_HEADERS, T as X402_HEADER_NAMES, c0 as ZERO_ADDRESS, c1 as buildErc8004PaymentRequirements, Z as buildPaymentConflictResponse, _ as buildPaymentRequirements, $ as buildSettleRequest, a0 as buildSettleRequestForVersion, a1 as buildSettleRequestV2, c2 as buildUnavailableResponse, a2 as buildVerifyRequest, a3 as buildVerifyRequestForVersion, a4 as buildVerifyRequestV2, c3 as canRefundEscrow, c4 as canReleaseEscrow, c5 as carryFailureFields, a5 as create402Response, a6 as createHonoMiddleware, a7 as createIdempotencyKey, a8 as createPaymentMiddleware, c6 as epochToDate, c7 as escrowTimeRemaining, a9 as extractPaymentFromHeaders, aa as facilitatorFetch, ab as getCorsHeaders, c8 as getEscrowContractsByChainId, c9 as getEscrowOperatorGeneration, ca as getEscrowSupportedChainIds, cb as isAlive, ac as isAmbiguousLeaseReason, ad as isAuthorizationAlreadyUsed, ae as isAuthorizationInFlight, cc as isEscrowExpired, cd as isEscrowSupportedOnChain, ce as isRegisterJobTerminal, af as isReplayableLeaseReason, ag as isSettlementUnconfirmed, ai as parseFacilitatorErrorBody, cf as parsePaymentHeader, aj as parseRetryAfterSeconds, ak as readFacilitatorError, al as resolveEnvelopeVersion, cg as supportsRelayedFeedback, ch as supportsSolanaFeedback, am as toPaymentRequirementsV2, an as toResourceInfoV2, ci as wireNetwork } from '../index-SaqboHsK.mjs';
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../wallet-w7BnImDG.js';
|
|
2
2
|
export { a as FacilitatorReceipt, F as FetchReceiptResult, P as PaymentState, b as PurchaseContext, c as RECEIPT_ISSUER, R as ReceiptFetchOptions, d as ReceiptKeys, e as canonicalReceiptJson, f as createPurchaseContext, g as fetchWithReceipt, h as getFacilitatorReceipt, m as mergeHeaderList, i as mergePaymentResponseHeaders, p as parseFacilitatorReceipt, j as paymentResponseHeaders, k as purchaseContextHeader, r as receiptCommitment, l as receiptFromErrorBody, n as receiptFromResponse, v as validatePurchaseContext, o as verifyFacilitatorReceipt } from '../receipts-Co6C9FPO.js';
|
|
3
3
|
import '../index-BsKsZzP3.js';
|
|
4
|
-
export { A as AMBIGUOUS_LEASE_REASONS, a as AUTHORIZATION_ALREADY_SETTLED, b as AUTHORIZATION_IN_FLIGHT, c as AdmittedAuthorizationCode, ap as AdvancedAuthorizationResult, aq as AdvancedEscrowClient, ar as AdvancedEscrowClientOptions, as as AdvancedEscrowContracts, at as AdvancedEscrowTaskTier, au as AdvancedPaymentInfo, av as AdvancedTransactionResult, aw as AgentId, ax as AgentIdentity, ay as AgentRegistration, az as AgentRegistrationFile, aA as AgentService, aB as AtomStats, aC as BASE_MAINNET_CONTRACTS, aD as BazaarClient, aE as BazaarClientOptions, aF as BazaarDiscoverOptions, aG as BazaarDiscoverResponse, aH as BazaarRegisterOptions, aI as BazaarResource, aJ as CreateEscrowOptions, D as DEFAULT_FACILITATOR_RETRIES, d as DEFAULT_RETRY_AFTER_SECONDS, aK as DEPOSIT_LIMIT_USDC, aL as DiscoveryAccepts, aM as DiscoveryCuration, aN as DiscoveryHealth, aO as DiscoveryHealthStatus, aP as DiscoveryListOptions, aQ as DiscoveryPagination, aR as DiscoveryRegisterOptions, aS as DiscoveryResource, aT as DiscoveryResponse, aU as DiscoverySource, aV as DiscoveryStats, aW as DiscoveryTier, aX as Dispute, aY as DisputeOutcome, aZ as ERC8004_CONTRACTS, a_ as ERC8004_EXTENSION_ID, a$ as ESCROW_CONTRACTS, b0 as
|
|
4
|
+
export { A as AMBIGUOUS_LEASE_REASONS, a as AUTHORIZATION_ALREADY_SETTLED, b as AUTHORIZATION_IN_FLIGHT, c as AdmittedAuthorizationCode, ap as AdvancedAuthorizationResult, aq as AdvancedEscrowClient, ar as AdvancedEscrowClientOptions, as as AdvancedEscrowContracts, at as AdvancedEscrowTaskTier, au as AdvancedPaymentInfo, av as AdvancedTransactionResult, aw as AgentId, ax as AgentIdentity, ay as AgentRegistration, az as AgentRegistrationFile, aA as AgentService, aB as AtomStats, aC as BASE_MAINNET_CONTRACTS, aD as BazaarClient, aE as BazaarClientOptions, aF as BazaarDiscoverOptions, aG as BazaarDiscoverResponse, aH as BazaarRegisterOptions, aI as BazaarResource, aJ as CreateEscrowOptions, D as DEFAULT_FACILITATOR_RETRIES, d as DEFAULT_RETRY_AFTER_SECONDS, aK as DEPOSIT_LIMIT_USDC, aL as DiscoveryAccepts, aM as DiscoveryCuration, aN as DiscoveryHealth, aO as DiscoveryHealthStatus, aP as DiscoveryListOptions, aQ as DiscoveryPagination, aR as DiscoveryRegisterOptions, aS as DiscoveryResource, aT as DiscoveryResponse, aU as DiscoverySource, aV as DiscoveryStats, aW as DiscoveryTier, aX as Dispute, aY as DisputeOutcome, aZ as ERC8004_CONTRACTS, a_ as ERC8004_EXTENSION_ID, a$ as ESCROW_CONTRACTS, b0 as ESCROW_NOTHING_TO_VOID, b1 as ESCROW_OPERATOR_GENERATION, b2 as ESCROW_OPERATOR_NOT_DEPLOYED, b3 as ESCROW_TIMEOUT_MS, b4 as ESCROW_UNSUPPORTED_ON_GENERATION, b5 as ESCROW_VOID_AMOUNT_MISMATCH, b6 as Erc8004Client, b7 as Erc8004ClientOptions, b8 as Erc8004LookupError, b9 as Erc8004Network, ba as EscrowClient, bb as EscrowClientOptions, bc as EscrowOperatorGeneration, bd as EscrowPayment, be as EscrowStateResponse, bf as EscrowStatus, F as FacilitatorCallOptions, e as FacilitatorClient, f as FacilitatorClientOptions, g as FacilitatorErrorInfo, h as FacilitatorFailureFields, i as FacilitatorFetchOptions, bg as FeedbackEntry, bh as FeedbackParams, bi as FeedbackRequest, bj as FeedbackResponse, bk as HEALTH_FILTERS, H as HonoMiddlewareOptions, I as IDEMPOTENCY_KEY_HEADER, j as IDEMPOTENT_REPLAYED_HEADER, bl as IdentityByOwnerResponse, bm as IdentityMetadataResponse, bn as IdentityTotalSupplyResponse, bo as LifecycleAuthOptions, M as MAX_RETRY_AFTER_SECONDS, bp as MAX_SEARCH_LEN, bq as MetadataEntryParam, br as OPERATOR_ABI, bs as OPERATOR_ABI_CREATE3, bt as OPERATOR_ABI_V3, bu as PAYMENT_INFO_TYPEHASH, P as ParsedFacilitatorErrorBody, v as PaymentAcceptance, w as PaymentConflictResponse, x as PaymentMiddlewareOptions, y as PaymentPayloadV2, bv as PaymentRequirementResolver, bw as PaymentRequirements, bx as PaymentRequirementsOptions, z as PaymentRequirementsV2, by as PrepareRelayFeedbackRequest, bz as PrepareRelayFeedbackResponse, bA as PrepareRelayResponseRequest, bB as PrepareSolanaFeedbackRequest, bC as PrepareSolanaFeedbackResponse, bD as ProofOfPayment, R as RECEIPT_REQUEST_CONFLICT, bE as RELAYED_FEEDBACK_NETWORKS, C as REPLAYABLE_LEASE_REASONS, bF as RefundRequest, bG as RefundStatus, bH as RegisterAgentRequest, bI as RegisterAgentResponse, bJ as RegisterJobResponse, bK as RegisterJobStatus, bL as RegistrationPendingError, bM as RelayAuthorizationParams, bN as ReputationResponse, bO as ReputationSummary, bP as RequestRefundOptions, E as ResourceInfoV2, S as SETTLEMENT_UNCONFIRMED, bQ as SOLANA_FEEDBACK_NETWORKS, bR as SettleRequest, G as SettleRequestV2, J as SettleResponse, bS as SettleResponseWithProof, bT as SubmitRelayFeedbackRequest, bU as SubmitRelayResponseRequest, bV as SubmitSolanaFeedbackRequest, bW as TIER_FILTERS, bX as TIER_TIMINGS, bY as USDC_DOMAIN_NAME, bZ as UnavailableBody, b_ as UnavailableResponse, V as VerifiedPaymentState, b$ as VerifyRequest, K as VerifyRequestV2, N as VerifyResponse, W as WRITER_LEASE_REASONS, Q as WriterLeaseReason, X as X402_CORS_HEADERS, T as X402_HEADER_NAMES, c0 as ZERO_ADDRESS, c1 as buildErc8004PaymentRequirements, Z as buildPaymentConflictResponse, _ as buildPaymentRequirements, $ as buildSettleRequest, a0 as buildSettleRequestForVersion, a1 as buildSettleRequestV2, c2 as buildUnavailableResponse, a2 as buildVerifyRequest, a3 as buildVerifyRequestForVersion, a4 as buildVerifyRequestV2, c3 as canRefundEscrow, c4 as canReleaseEscrow, c5 as carryFailureFields, a5 as create402Response, a6 as createHonoMiddleware, a7 as createIdempotencyKey, a8 as createPaymentMiddleware, c6 as epochToDate, c7 as escrowTimeRemaining, a9 as extractPaymentFromHeaders, aa as facilitatorFetch, ab as getCorsHeaders, c8 as getEscrowContractsByChainId, c9 as getEscrowOperatorGeneration, ca as getEscrowSupportedChainIds, cb as isAlive, ac as isAmbiguousLeaseReason, ad as isAuthorizationAlreadyUsed, ae as isAuthorizationInFlight, cc as isEscrowExpired, cd as isEscrowSupportedOnChain, ce as isRegisterJobTerminal, af as isReplayableLeaseReason, ag as isSettlementUnconfirmed, ai as parseFacilitatorErrorBody, cf as parsePaymentHeader, aj as parseRetryAfterSeconds, ak as readFacilitatorError, al as resolveEnvelopeVersion, cg as supportsRelayedFeedback, ch as supportsSolanaFeedback, am as toPaymentRequirementsV2, an as toResourceInfoV2, ci as wireNetwork } from '../index-BiL4seGs.js';
|
package/dist/backend/index.js
CHANGED
|
@@ -1521,6 +1521,13 @@ var DEFAULT_MIN_FEE_BPS = 0;
|
|
|
1521
1521
|
var DEFAULT_MAX_FEE_BPS = OPERATOR_FEE_BPS + MAX_PROTOCOL_FEE_BPS;
|
|
1522
1522
|
var REVIEW_WINDOW_SEC = 7 * 24 * 3600;
|
|
1523
1523
|
var REFUND_WINDOW_SEC = 7 * 24 * 3600;
|
|
1524
|
+
Object.fromEntries(
|
|
1525
|
+
["arc", "arc-testnet"].map((network) => {
|
|
1526
|
+
const chain = getChainByName(network);
|
|
1527
|
+
if (!chain) throw new Error(`The chain registry has no '${network}'.`);
|
|
1528
|
+
return [chain.chainId, { name: chain.usdc.name, version: chain.usdc.version }];
|
|
1529
|
+
})
|
|
1530
|
+
);
|
|
1524
1531
|
var LIFECYCLE_DOMAIN_NAME = "x402 escrow lifecycle";
|
|
1525
1532
|
var LIFECYCLE_DOMAIN_VERSION = "1";
|
|
1526
1533
|
var LIFECYCLE_MAX_DEADLINE_SECS = 900;
|
|
@@ -4942,6 +4949,11 @@ var ESCROW_TIMEOUT_MS = {
|
|
|
4942
4949
|
// Monad: 90s
|
|
4943
4950
|
};
|
|
4944
4951
|
var DEFAULT_ESCROW_TIMEOUT_MS = 3e4;
|
|
4952
|
+
function arcUsdc(network) {
|
|
4953
|
+
const chain = getChainByName(network);
|
|
4954
|
+
if (!chain) throw new Error(`The chain registry has no '${network}'.`);
|
|
4955
|
+
return chain.usdc;
|
|
4956
|
+
}
|
|
4945
4957
|
var USDC_DOMAIN_NAME = {
|
|
4946
4958
|
8453: "USD Coin",
|
|
4947
4959
|
// Base Mainnet
|
|
@@ -4959,8 +4971,12 @@ var USDC_DOMAIN_NAME = {
|
|
|
4959
4971
|
// Avalanche
|
|
4960
4972
|
42220: "USDC",
|
|
4961
4973
|
// Celo
|
|
4962
|
-
143: "USDC"
|
|
4974
|
+
143: "USDC",
|
|
4963
4975
|
// Monad
|
|
4976
|
+
5042: arcUsdc("arc").name,
|
|
4977
|
+
// Arc ('USDC', from src/chains)
|
|
4978
|
+
5042002: arcUsdc("arc-testnet").name
|
|
4979
|
+
// Arc Testnet ('USDC', from src/chains)
|
|
4964
4980
|
};
|
|
4965
4981
|
var ESCROW_CONTRACTS = {
|
|
4966
4982
|
// Base Sepolia (testnet, chain 84532)
|
|
@@ -5061,6 +5077,24 @@ var ESCROW_CONTRACTS = {
|
|
|
5061
5077
|
protocolFeeConfig: "0xf62788834C99B2E85a6891C0b46D1EB996f8f596",
|
|
5062
5078
|
refundRequest: "0x69e9BF2b40Ed472b55E47e9D4205d93Ed673093F",
|
|
5063
5079
|
usdc: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"
|
|
5080
|
+
},
|
|
5081
|
+
// Arc (chain 5042) - x402r canonical escrow, 'v3' operator
|
|
5082
|
+
5042: {
|
|
5083
|
+
operator: "0x0258472A1410Ac3Ad720f1BC83f22B3c0af1Fd9D",
|
|
5084
|
+
escrow: "0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff",
|
|
5085
|
+
tokenCollector: "0x0E3dF9510de65469C4518D7843919c0b8C7A7757",
|
|
5086
|
+
protocolFeeConfig: "0xBe2d24614F339a1eB103A399F93AA2a39Ca815Bc",
|
|
5087
|
+
refundRequest: "0xe971C674fD5c3462023f3F891dF6289DFbC9CEFC",
|
|
5088
|
+
usdc: arcUsdc("arc").address
|
|
5089
|
+
},
|
|
5090
|
+
// Arc Testnet (chain 5042002) - same canonical addresses as Arc
|
|
5091
|
+
5042002: {
|
|
5092
|
+
operator: "0x0258472A1410Ac3Ad720f1BC83f22B3c0af1Fd9D",
|
|
5093
|
+
escrow: "0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff",
|
|
5094
|
+
tokenCollector: "0x0E3dF9510de65469C4518D7843919c0b8C7A7757",
|
|
5095
|
+
protocolFeeConfig: "0xBe2d24614F339a1eB103A399F93AA2a39Ca815Bc",
|
|
5096
|
+
refundRequest: "0xe971C674fD5c3462023f3F891dF6289DFbC9CEFC",
|
|
5097
|
+
usdc: arcUsdc("arc-testnet").address
|
|
5064
5098
|
}
|
|
5065
5099
|
};
|
|
5066
5100
|
var BASE_MAINNET_CONTRACTS = ESCROW_CONTRACTS[8453];
|
|
@@ -5110,7 +5144,56 @@ var OPERATOR_ABI_CREATE3 = [
|
|
|
5110
5144
|
"function charge(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo, uint256 amount, address tokenCollector, bytes collectorData)",
|
|
5111
5145
|
"function refundPostEscrow(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo, uint256 amount, address tokenCollector, bytes collectorData)"
|
|
5112
5146
|
];
|
|
5113
|
-
var
|
|
5147
|
+
var OPERATOR_ABI_V3 = [
|
|
5148
|
+
"function capture(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo, uint256 amount, bytes data)",
|
|
5149
|
+
"function void(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo, bytes data)",
|
|
5150
|
+
"function refund(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo, uint256 amount, address tokenCollector, bytes collectorData)",
|
|
5151
|
+
"function FEE_RECEIVER() view returns (address)",
|
|
5152
|
+
"function AUTHORIZE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5153
|
+
"function CHARGE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5154
|
+
"function CAPTURE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5155
|
+
"function VOID_PRE_ACTION_CONDITION() view returns (address)",
|
|
5156
|
+
"function REFUND_PRE_ACTION_CONDITION() view returns (address)"
|
|
5157
|
+
];
|
|
5158
|
+
var AUTH_CAPTURE_ESCROW_STATE_ABI = [
|
|
5159
|
+
"function getHash(tuple(address operator, address payer, address receiver, address token, uint120 maxAmount, uint48 preApprovalExpiry, uint48 authorizationExpiry, uint48 refundExpiry, uint16 minFeeBps, uint16 maxFeeBps, address feeReceiver, uint256 salt) paymentInfo) view returns (bytes32)",
|
|
5160
|
+
"function paymentState(bytes32 paymentInfoHash) view returns (bool hasCollectedPayment, uint120 capturableAmount, uint120 refundableAmount)"
|
|
5161
|
+
];
|
|
5162
|
+
var ESCROW_VOID_AMOUNT_MISMATCH = "escrow_void_amount_mismatch";
|
|
5163
|
+
var ESCROW_NOTHING_TO_VOID = "escrow_nothing_to_void";
|
|
5164
|
+
var ESCROW_OPERATOR_NOT_DEPLOYED = "escrow_operator_not_deployed";
|
|
5165
|
+
var ESCROW_UNSUPPORTED_ON_GENERATION = "escrow_unsupported_on_generation";
|
|
5166
|
+
var ESCROW_OPERATOR_GENERATION = {
|
|
5167
|
+
84532: "v1",
|
|
5168
|
+
// Base Sepolia
|
|
5169
|
+
8453: "v1",
|
|
5170
|
+
// Base
|
|
5171
|
+
11155111: "v1",
|
|
5172
|
+
// Ethereum Sepolia
|
|
5173
|
+
1: "v1",
|
|
5174
|
+
// Ethereum
|
|
5175
|
+
137: "v1",
|
|
5176
|
+
// Polygon
|
|
5177
|
+
42161: "v1",
|
|
5178
|
+
// Arbitrum
|
|
5179
|
+
42220: "v1",
|
|
5180
|
+
// Celo
|
|
5181
|
+
143: "v1",
|
|
5182
|
+
// Monad
|
|
5183
|
+
43114: "v1",
|
|
5184
|
+
// Avalanche
|
|
5185
|
+
10: "v1",
|
|
5186
|
+
// Optimism
|
|
5187
|
+
1187947933: "v2",
|
|
5188
|
+
// SKALE Base
|
|
5189
|
+
5042: "v3",
|
|
5190
|
+
// Arc
|
|
5191
|
+
5042002: "v3"
|
|
5192
|
+
// Arc Testnet
|
|
5193
|
+
};
|
|
5194
|
+
function getEscrowOperatorGeneration(chainId) {
|
|
5195
|
+
return ESCROW_OPERATOR_GENERATION[chainId] ?? "v1";
|
|
5196
|
+
}
|
|
5114
5197
|
var AdvancedEscrowClient = class {
|
|
5115
5198
|
facilitatorUrl;
|
|
5116
5199
|
chainId;
|
|
@@ -5416,6 +5499,10 @@ var AdvancedEscrowClient = class {
|
|
|
5416
5499
|
*
|
|
5417
5500
|
* Calls PaymentOperator.release() -> escrow.capture()
|
|
5418
5501
|
*
|
|
5502
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5503
|
+
* `PaymentOperator.capture(paymentInfo, amount, 0x)` instead, after checking
|
|
5504
|
+
* that the operator has code ({@link ESCROW_OPERATOR_NOT_DEPLOYED}).
|
|
5505
|
+
*
|
|
5419
5506
|
* @param paymentInfo - PaymentInfo from the authorize step
|
|
5420
5507
|
* @param amount - Amount to release (defaults to maxAmount)
|
|
5421
5508
|
*/
|
|
@@ -5423,10 +5510,14 @@ var AdvancedEscrowClient = class {
|
|
|
5423
5510
|
if (!this.payerAddress) await this.init();
|
|
5424
5511
|
try {
|
|
5425
5512
|
const { ethers: ethers4 } = await import('ethers');
|
|
5426
|
-
const
|
|
5513
|
+
const generation = getEscrowOperatorGeneration(this.chainId);
|
|
5514
|
+
const isCreate3 = generation === "v2";
|
|
5427
5515
|
const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
|
|
5428
5516
|
const amt = amount || paymentInfo.maxAmount;
|
|
5429
5517
|
const tuple = this.buildTuple(paymentInfo);
|
|
5518
|
+
if (generation === "v3") {
|
|
5519
|
+
return await this.sendV3OperatorCall(ethers4, this.v3Provider(ethers4), "capture", [tuple, amt, "0x"]);
|
|
5520
|
+
}
|
|
5430
5521
|
if (this.walletAdapter) {
|
|
5431
5522
|
return this.sendViaAdapter(ethers4, abi, (iface) => {
|
|
5432
5523
|
return isCreate3 ? iface.encodeFunctionData("release", [tuple, amt, "0x"]) : iface.encodeFunctionData("release", [tuple, amt]);
|
|
@@ -5450,6 +5541,16 @@ var AdvancedEscrowClient = class {
|
|
|
5450
5541
|
*
|
|
5451
5542
|
* Calls PaymentOperator.refundInEscrow() -> escrow.partialVoid()
|
|
5452
5543
|
*
|
|
5544
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5545
|
+
* `PaymentOperator.void(paymentInfo, 0x)`, which takes no amount and returns
|
|
5546
|
+
* the WHOLE `capturableAmount`. So it first reads that amount on-chain
|
|
5547
|
+
* (`AuthCaptureEscrow.getHash` + `paymentState`) and sends only when
|
|
5548
|
+
* `amount` equals it. Otherwise nothing is sent and `errorCode` says why:
|
|
5549
|
+
* {@link ESCROW_NOTHING_TO_VOID} when it is 0,
|
|
5550
|
+
* {@link ESCROW_VOID_AMOUNT_MISMATCH} for any other amount. To return part
|
|
5551
|
+
* of an escrow on v3, `release` the part the receiver keeps, then
|
|
5552
|
+
* `refundInEscrow` what is left.
|
|
5553
|
+
*
|
|
5453
5554
|
* @param paymentInfo - PaymentInfo from the authorize step
|
|
5454
5555
|
* @param amount - Amount to refund (defaults to maxAmount)
|
|
5455
5556
|
*/
|
|
@@ -5457,10 +5558,14 @@ var AdvancedEscrowClient = class {
|
|
|
5457
5558
|
if (!this.payerAddress) await this.init();
|
|
5458
5559
|
try {
|
|
5459
5560
|
const { ethers: ethers4 } = await import('ethers');
|
|
5460
|
-
const
|
|
5561
|
+
const generation = getEscrowOperatorGeneration(this.chainId);
|
|
5562
|
+
const isCreate3 = generation === "v2";
|
|
5461
5563
|
const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
|
|
5462
5564
|
const amt = amount || paymentInfo.maxAmount;
|
|
5463
5565
|
const tuple = this.buildTuple(paymentInfo);
|
|
5566
|
+
if (generation === "v3") {
|
|
5567
|
+
return await this.voidWholeCapturable(ethers4, tuple, amt);
|
|
5568
|
+
}
|
|
5464
5569
|
if (this.walletAdapter) {
|
|
5465
5570
|
return this.sendViaAdapter(ethers4, abi, (iface) => {
|
|
5466
5571
|
return isCreate3 ? iface.encodeFunctionData("refundInEscrow", [tuple, amt, "0x"]) : iface.encodeFunctionData("refundInEscrow", [tuple, amt]);
|
|
@@ -5795,10 +5900,15 @@ var AdvancedEscrowClient = class {
|
|
|
5795
5900
|
* Calls PaymentOperator.charge() -> escrow.charge()
|
|
5796
5901
|
* Funds go directly from payer to receiver.
|
|
5797
5902
|
*
|
|
5903
|
+
* Not available on a `'v3'` operator (Arc, Arc Testnet): it returns
|
|
5904
|
+
* {@link ESCROW_UNSUPPORTED_ON_GENERATION} without signing or sending.
|
|
5905
|
+
*
|
|
5798
5906
|
* @param paymentInfo - PaymentInfo with receiver and amount
|
|
5799
5907
|
* @param amount - Amount to charge (defaults to maxAmount)
|
|
5800
5908
|
*/
|
|
5801
5909
|
async charge(paymentInfo, amount) {
|
|
5910
|
+
const unsupported = this.unsupportedOnV3("charge");
|
|
5911
|
+
if (unsupported) return unsupported;
|
|
5802
5912
|
if (!this.payerAddress) await this.init();
|
|
5803
5913
|
try {
|
|
5804
5914
|
const { ethers: ethers4 } = await import('ethers');
|
|
@@ -5859,6 +5969,11 @@ var AdvancedEscrowClient = class {
|
|
|
5859
5969
|
*
|
|
5860
5970
|
* Kept for future use when tokenCollector is implemented.
|
|
5861
5971
|
*
|
|
5972
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5973
|
+
* `PaymentOperator.refund(paymentInfo, amount, tokenCollector, collectorData)`
|
|
5974
|
+
* -> escrow.refund(), the same arguments, after checking that the operator
|
|
5975
|
+
* has code ({@link ESCROW_OPERATOR_NOT_DEPLOYED}).
|
|
5976
|
+
*
|
|
5862
5977
|
* @param paymentInfo - PaymentInfo from the original authorization
|
|
5863
5978
|
* @param amount - Amount to refund (defaults to maxAmount)
|
|
5864
5979
|
* @param tokenCollector - Address of token collector for refund sourcing
|
|
@@ -5870,6 +5985,14 @@ var AdvancedEscrowClient = class {
|
|
|
5870
5985
|
const { ethers: ethers4 } = await import('ethers');
|
|
5871
5986
|
const amt = amount || paymentInfo.maxAmount;
|
|
5872
5987
|
const tuple = this.buildTuple(paymentInfo);
|
|
5988
|
+
if (getEscrowOperatorGeneration(this.chainId) === "v3") {
|
|
5989
|
+
return await this.sendV3OperatorCall(ethers4, this.v3Provider(ethers4), "refund", [
|
|
5990
|
+
tuple,
|
|
5991
|
+
amt,
|
|
5992
|
+
tokenCollector || ZERO_ADDRESS,
|
|
5993
|
+
collectorData || "0x"
|
|
5994
|
+
]);
|
|
5995
|
+
}
|
|
5873
5996
|
if (this.walletAdapter) {
|
|
5874
5997
|
return this.sendViaAdapter(ethers4, OPERATOR_ABI, (iface) => {
|
|
5875
5998
|
return iface.encodeFunctionData("refundPostEscrow", [
|
|
@@ -5900,6 +6023,89 @@ var AdvancedEscrowClient = class {
|
|
|
5900
6023
|
}
|
|
5901
6024
|
}
|
|
5902
6025
|
// ==========================================================================
|
|
6026
|
+
// INTERNAL: 'v3' operator (Arc, Arc Testnet)
|
|
6027
|
+
// ==========================================================================
|
|
6028
|
+
/** The refusal of a call a 'v3' operator does not have, or null elsewhere. */
|
|
6029
|
+
unsupportedOnV3(method) {
|
|
6030
|
+
if (getEscrowOperatorGeneration(this.chainId) !== "v3") return null;
|
|
6031
|
+
return {
|
|
6032
|
+
success: false,
|
|
6033
|
+
errorCode: ESCROW_UNSUPPORTED_ON_GENERATION,
|
|
6034
|
+
error: `${method} is not available on the v3 escrow operator of chain ${this.chainId} (OPERATOR_ABI_V3). Nothing was signed or sent.`
|
|
6035
|
+
};
|
|
6036
|
+
}
|
|
6037
|
+
/** The provider a 'v3' call reads with before it sends anything. */
|
|
6038
|
+
v3Provider(ethersModule) {
|
|
6039
|
+
const provider = this.walletAdapter ? new ethersModule.JsonRpcProvider(this.rpcUrl) : this.signer?.provider;
|
|
6040
|
+
if (!provider) {
|
|
6041
|
+
throw new Error(
|
|
6042
|
+
`AdvancedEscrowClient: chain ${this.chainId} uses a v3 escrow operator, which is read on-chain before any call; the signer has no provider to read with.`
|
|
6043
|
+
);
|
|
6044
|
+
}
|
|
6045
|
+
return provider;
|
|
6046
|
+
}
|
|
6047
|
+
/**
|
|
6048
|
+
* Send one OPERATOR_ABI_V3 call, once the operator is known to have code.
|
|
6049
|
+
* A call to an address with no code succeeds and moves nothing, and would be
|
|
6050
|
+
* reported as a success.
|
|
6051
|
+
*/
|
|
6052
|
+
async sendV3OperatorCall(ethersModule, provider, method, args) {
|
|
6053
|
+
const code = await provider.getCode(this.contracts.operator);
|
|
6054
|
+
if (!code || code === "0x") {
|
|
6055
|
+
return {
|
|
6056
|
+
success: false,
|
|
6057
|
+
errorCode: ESCROW_OPERATOR_NOT_DEPLOYED,
|
|
6058
|
+
error: `The escrow operator ${this.contracts.operator} has no code on chain ${this.chainId}. Nothing was sent.`
|
|
6059
|
+
};
|
|
6060
|
+
}
|
|
6061
|
+
if (this.walletAdapter) {
|
|
6062
|
+
return await this.sendViaAdapter(
|
|
6063
|
+
ethersModule,
|
|
6064
|
+
OPERATOR_ABI_V3,
|
|
6065
|
+
(iface) => iface.encodeFunctionData(method, args)
|
|
6066
|
+
);
|
|
6067
|
+
}
|
|
6068
|
+
const contract = new ethersModule.Contract(this.contracts.operator, OPERATOR_ABI_V3, this.signer);
|
|
6069
|
+
const tx = await contract.getFunction(method)(...args, { gasLimit: this.gasLimit });
|
|
6070
|
+
const receipt = await tx.wait();
|
|
6071
|
+
return {
|
|
6072
|
+
success: receipt.status === 1,
|
|
6073
|
+
transactionHash: receipt.hash,
|
|
6074
|
+
gasUsed: Number(receipt.gasUsed),
|
|
6075
|
+
error: receipt.status !== 1 ? "Transaction reverted" : void 0
|
|
6076
|
+
};
|
|
6077
|
+
}
|
|
6078
|
+
/**
|
|
6079
|
+
* `refundInEscrow` on a 'v3' operator: `void` returns the whole capturable
|
|
6080
|
+
* amount, so it is sent only when that is exactly what was asked for.
|
|
6081
|
+
*/
|
|
6082
|
+
async voidWholeCapturable(ethersModule, tuple, amount) {
|
|
6083
|
+
const requested = BigInt(amount);
|
|
6084
|
+
if (requested <= 0n) {
|
|
6085
|
+
return { success: false, error: `refundInEscrow amount must be positive, got ${amount}. Nothing was sent.` };
|
|
6086
|
+
}
|
|
6087
|
+
const provider = this.v3Provider(ethersModule);
|
|
6088
|
+
const escrow = new ethersModule.Contract(this.contracts.escrow, AUTH_CAPTURE_ESCROW_STATE_ABI, provider);
|
|
6089
|
+
const paymentInfoHash = await escrow.getHash(tuple);
|
|
6090
|
+
const [, capturable] = await escrow.paymentState(paymentInfoHash);
|
|
6091
|
+
const capturableAmount = BigInt(capturable);
|
|
6092
|
+
if (capturableAmount === 0n) {
|
|
6093
|
+
return {
|
|
6094
|
+
success: false,
|
|
6095
|
+
errorCode: ESCROW_NOTHING_TO_VOID,
|
|
6096
|
+
error: `Nothing to void on chain ${this.chainId}: capturableAmount is 0 for payment ${paymentInfoHash}. Nothing was sent.`
|
|
6097
|
+
};
|
|
6098
|
+
}
|
|
6099
|
+
if (requested !== capturableAmount) {
|
|
6100
|
+
return {
|
|
6101
|
+
success: false,
|
|
6102
|
+
errorCode: ESCROW_VOID_AMOUNT_MISMATCH,
|
|
6103
|
+
error: `refundInEscrow asked for ${requested} but the v3 operator's void() returns the whole capturableAmount, ${capturableAmount}. Pass ${capturableAmount}, or release the part the receiver keeps first. Nothing was sent.`
|
|
6104
|
+
};
|
|
6105
|
+
}
|
|
6106
|
+
return await this.sendV3OperatorCall(ethersModule, provider, "void", [tuple, "0x"]);
|
|
6107
|
+
}
|
|
6108
|
+
// ==========================================================================
|
|
5903
6109
|
// INTERNAL: Adapter-based transaction signing and broadcast
|
|
5904
6110
|
// ==========================================================================
|
|
5905
6111
|
/**
|
|
@@ -5955,7 +6161,12 @@ exports.DEPOSIT_LIMIT_USDC = DEPOSIT_LIMIT_USDC;
|
|
|
5955
6161
|
exports.ERC8004_CONTRACTS = ERC8004_CONTRACTS;
|
|
5956
6162
|
exports.ERC8004_EXTENSION_ID = ERC8004_EXTENSION_ID;
|
|
5957
6163
|
exports.ESCROW_CONTRACTS = ESCROW_CONTRACTS;
|
|
6164
|
+
exports.ESCROW_NOTHING_TO_VOID = ESCROW_NOTHING_TO_VOID;
|
|
6165
|
+
exports.ESCROW_OPERATOR_GENERATION = ESCROW_OPERATOR_GENERATION;
|
|
6166
|
+
exports.ESCROW_OPERATOR_NOT_DEPLOYED = ESCROW_OPERATOR_NOT_DEPLOYED;
|
|
5958
6167
|
exports.ESCROW_TIMEOUT_MS = ESCROW_TIMEOUT_MS;
|
|
6168
|
+
exports.ESCROW_UNSUPPORTED_ON_GENERATION = ESCROW_UNSUPPORTED_ON_GENERATION;
|
|
6169
|
+
exports.ESCROW_VOID_AMOUNT_MISMATCH = ESCROW_VOID_AMOUNT_MISMATCH;
|
|
5959
6170
|
exports.Erc8004Client = Erc8004Client;
|
|
5960
6171
|
exports.Erc8004LookupError = Erc8004LookupError;
|
|
5961
6172
|
exports.EscrowClient = EscrowClient;
|
|
@@ -5967,6 +6178,7 @@ exports.MAX_RETRY_AFTER_SECONDS = MAX_RETRY_AFTER_SECONDS;
|
|
|
5967
6178
|
exports.MAX_SEARCH_LEN = MAX_SEARCH_LEN;
|
|
5968
6179
|
exports.OPERATOR_ABI = OPERATOR_ABI;
|
|
5969
6180
|
exports.OPERATOR_ABI_CREATE3 = OPERATOR_ABI_CREATE3;
|
|
6181
|
+
exports.OPERATOR_ABI_V3 = OPERATOR_ABI_V3;
|
|
5970
6182
|
exports.PAYMENT_INFO_TYPEHASH = PAYMENT_INFO_TYPEHASH;
|
|
5971
6183
|
exports.RECEIPT_ISSUER = RECEIPT_ISSUER;
|
|
5972
6184
|
exports.RECEIPT_REQUEST_CONFLICT = RECEIPT_REQUEST_CONFLICT;
|
|
@@ -6008,6 +6220,7 @@ exports.facilitatorFetch = facilitatorFetch;
|
|
|
6008
6220
|
exports.fetchWithReceipt = fetchWithReceipt;
|
|
6009
6221
|
exports.getCorsHeaders = getCorsHeaders;
|
|
6010
6222
|
exports.getEscrowContractsByChainId = getEscrowContractsByChainId;
|
|
6223
|
+
exports.getEscrowOperatorGeneration = getEscrowOperatorGeneration;
|
|
6011
6224
|
exports.getEscrowSupportedChainIds = getEscrowSupportedChainIds;
|
|
6012
6225
|
exports.getFacilitatorReceipt = getFacilitatorReceipt;
|
|
6013
6226
|
exports.isAlive = isAlive;
|