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/dist/backend/index.mjs
CHANGED
|
@@ -1519,6 +1519,13 @@ var DEFAULT_MIN_FEE_BPS = 0;
|
|
|
1519
1519
|
var DEFAULT_MAX_FEE_BPS = OPERATOR_FEE_BPS + MAX_PROTOCOL_FEE_BPS;
|
|
1520
1520
|
var REVIEW_WINDOW_SEC = 7 * 24 * 3600;
|
|
1521
1521
|
var REFUND_WINDOW_SEC = 7 * 24 * 3600;
|
|
1522
|
+
Object.fromEntries(
|
|
1523
|
+
["arc", "arc-testnet"].map((network) => {
|
|
1524
|
+
const chain = getChainByName(network);
|
|
1525
|
+
if (!chain) throw new Error(`The chain registry has no '${network}'.`);
|
|
1526
|
+
return [chain.chainId, { name: chain.usdc.name, version: chain.usdc.version }];
|
|
1527
|
+
})
|
|
1528
|
+
);
|
|
1522
1529
|
var LIFECYCLE_DOMAIN_NAME = "x402 escrow lifecycle";
|
|
1523
1530
|
var LIFECYCLE_DOMAIN_VERSION = "1";
|
|
1524
1531
|
var LIFECYCLE_MAX_DEADLINE_SECS = 900;
|
|
@@ -4940,6 +4947,11 @@ var ESCROW_TIMEOUT_MS = {
|
|
|
4940
4947
|
// Monad: 90s
|
|
4941
4948
|
};
|
|
4942
4949
|
var DEFAULT_ESCROW_TIMEOUT_MS = 3e4;
|
|
4950
|
+
function arcUsdc(network) {
|
|
4951
|
+
const chain = getChainByName(network);
|
|
4952
|
+
if (!chain) throw new Error(`The chain registry has no '${network}'.`);
|
|
4953
|
+
return chain.usdc;
|
|
4954
|
+
}
|
|
4943
4955
|
var USDC_DOMAIN_NAME = {
|
|
4944
4956
|
8453: "USD Coin",
|
|
4945
4957
|
// Base Mainnet
|
|
@@ -4957,8 +4969,12 @@ var USDC_DOMAIN_NAME = {
|
|
|
4957
4969
|
// Avalanche
|
|
4958
4970
|
42220: "USDC",
|
|
4959
4971
|
// Celo
|
|
4960
|
-
143: "USDC"
|
|
4972
|
+
143: "USDC",
|
|
4961
4973
|
// Monad
|
|
4974
|
+
5042: arcUsdc("arc").name,
|
|
4975
|
+
// Arc ('USDC', from src/chains)
|
|
4976
|
+
5042002: arcUsdc("arc-testnet").name
|
|
4977
|
+
// Arc Testnet ('USDC', from src/chains)
|
|
4962
4978
|
};
|
|
4963
4979
|
var ESCROW_CONTRACTS = {
|
|
4964
4980
|
// Base Sepolia (testnet, chain 84532)
|
|
@@ -5059,6 +5075,24 @@ var ESCROW_CONTRACTS = {
|
|
|
5059
5075
|
protocolFeeConfig: "0xf62788834C99B2E85a6891C0b46D1EB996f8f596",
|
|
5060
5076
|
refundRequest: "0x69e9BF2b40Ed472b55E47e9D4205d93Ed673093F",
|
|
5061
5077
|
usdc: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20"
|
|
5078
|
+
},
|
|
5079
|
+
// Arc (chain 5042) - x402r canonical escrow, 'v3' operator
|
|
5080
|
+
5042: {
|
|
5081
|
+
operator: "0x0258472A1410Ac3Ad720f1BC83f22B3c0af1Fd9D",
|
|
5082
|
+
escrow: "0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff",
|
|
5083
|
+
tokenCollector: "0x0E3dF9510de65469C4518D7843919c0b8C7A7757",
|
|
5084
|
+
protocolFeeConfig: "0xBe2d24614F339a1eB103A399F93AA2a39Ca815Bc",
|
|
5085
|
+
refundRequest: "0xe971C674fD5c3462023f3F891dF6289DFbC9CEFC",
|
|
5086
|
+
usdc: arcUsdc("arc").address
|
|
5087
|
+
},
|
|
5088
|
+
// Arc Testnet (chain 5042002) - same canonical addresses as Arc
|
|
5089
|
+
5042002: {
|
|
5090
|
+
operator: "0x0258472A1410Ac3Ad720f1BC83f22B3c0af1Fd9D",
|
|
5091
|
+
escrow: "0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff",
|
|
5092
|
+
tokenCollector: "0x0E3dF9510de65469C4518D7843919c0b8C7A7757",
|
|
5093
|
+
protocolFeeConfig: "0xBe2d24614F339a1eB103A399F93AA2a39Ca815Bc",
|
|
5094
|
+
refundRequest: "0xe971C674fD5c3462023f3F891dF6289DFbC9CEFC",
|
|
5095
|
+
usdc: arcUsdc("arc-testnet").address
|
|
5062
5096
|
}
|
|
5063
5097
|
};
|
|
5064
5098
|
var BASE_MAINNET_CONTRACTS = ESCROW_CONTRACTS[8453];
|
|
@@ -5108,7 +5142,56 @@ var OPERATOR_ABI_CREATE3 = [
|
|
|
5108
5142
|
"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)",
|
|
5109
5143
|
"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)"
|
|
5110
5144
|
];
|
|
5111
|
-
var
|
|
5145
|
+
var OPERATOR_ABI_V3 = [
|
|
5146
|
+
"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)",
|
|
5147
|
+
"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)",
|
|
5148
|
+
"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)",
|
|
5149
|
+
"function FEE_RECEIVER() view returns (address)",
|
|
5150
|
+
"function AUTHORIZE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5151
|
+
"function CHARGE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5152
|
+
"function CAPTURE_PRE_ACTION_CONDITION() view returns (address)",
|
|
5153
|
+
"function VOID_PRE_ACTION_CONDITION() view returns (address)",
|
|
5154
|
+
"function REFUND_PRE_ACTION_CONDITION() view returns (address)"
|
|
5155
|
+
];
|
|
5156
|
+
var AUTH_CAPTURE_ESCROW_STATE_ABI = [
|
|
5157
|
+
"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)",
|
|
5158
|
+
"function paymentState(bytes32 paymentInfoHash) view returns (bool hasCollectedPayment, uint120 capturableAmount, uint120 refundableAmount)"
|
|
5159
|
+
];
|
|
5160
|
+
var ESCROW_VOID_AMOUNT_MISMATCH = "escrow_void_amount_mismatch";
|
|
5161
|
+
var ESCROW_NOTHING_TO_VOID = "escrow_nothing_to_void";
|
|
5162
|
+
var ESCROW_OPERATOR_NOT_DEPLOYED = "escrow_operator_not_deployed";
|
|
5163
|
+
var ESCROW_UNSUPPORTED_ON_GENERATION = "escrow_unsupported_on_generation";
|
|
5164
|
+
var ESCROW_OPERATOR_GENERATION = {
|
|
5165
|
+
84532: "v1",
|
|
5166
|
+
// Base Sepolia
|
|
5167
|
+
8453: "v1",
|
|
5168
|
+
// Base
|
|
5169
|
+
11155111: "v1",
|
|
5170
|
+
// Ethereum Sepolia
|
|
5171
|
+
1: "v1",
|
|
5172
|
+
// Ethereum
|
|
5173
|
+
137: "v1",
|
|
5174
|
+
// Polygon
|
|
5175
|
+
42161: "v1",
|
|
5176
|
+
// Arbitrum
|
|
5177
|
+
42220: "v1",
|
|
5178
|
+
// Celo
|
|
5179
|
+
143: "v1",
|
|
5180
|
+
// Monad
|
|
5181
|
+
43114: "v1",
|
|
5182
|
+
// Avalanche
|
|
5183
|
+
10: "v1",
|
|
5184
|
+
// Optimism
|
|
5185
|
+
1187947933: "v2",
|
|
5186
|
+
// SKALE Base
|
|
5187
|
+
5042: "v3",
|
|
5188
|
+
// Arc
|
|
5189
|
+
5042002: "v3"
|
|
5190
|
+
// Arc Testnet
|
|
5191
|
+
};
|
|
5192
|
+
function getEscrowOperatorGeneration(chainId) {
|
|
5193
|
+
return ESCROW_OPERATOR_GENERATION[chainId] ?? "v1";
|
|
5194
|
+
}
|
|
5112
5195
|
var AdvancedEscrowClient = class {
|
|
5113
5196
|
facilitatorUrl;
|
|
5114
5197
|
chainId;
|
|
@@ -5414,6 +5497,10 @@ var AdvancedEscrowClient = class {
|
|
|
5414
5497
|
*
|
|
5415
5498
|
* Calls PaymentOperator.release() -> escrow.capture()
|
|
5416
5499
|
*
|
|
5500
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5501
|
+
* `PaymentOperator.capture(paymentInfo, amount, 0x)` instead, after checking
|
|
5502
|
+
* that the operator has code ({@link ESCROW_OPERATOR_NOT_DEPLOYED}).
|
|
5503
|
+
*
|
|
5417
5504
|
* @param paymentInfo - PaymentInfo from the authorize step
|
|
5418
5505
|
* @param amount - Amount to release (defaults to maxAmount)
|
|
5419
5506
|
*/
|
|
@@ -5421,10 +5508,14 @@ var AdvancedEscrowClient = class {
|
|
|
5421
5508
|
if (!this.payerAddress) await this.init();
|
|
5422
5509
|
try {
|
|
5423
5510
|
const { ethers: ethers4 } = await import('ethers');
|
|
5424
|
-
const
|
|
5511
|
+
const generation = getEscrowOperatorGeneration(this.chainId);
|
|
5512
|
+
const isCreate3 = generation === "v2";
|
|
5425
5513
|
const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
|
|
5426
5514
|
const amt = amount || paymentInfo.maxAmount;
|
|
5427
5515
|
const tuple = this.buildTuple(paymentInfo);
|
|
5516
|
+
if (generation === "v3") {
|
|
5517
|
+
return await this.sendV3OperatorCall(ethers4, this.v3Provider(ethers4), "capture", [tuple, amt, "0x"]);
|
|
5518
|
+
}
|
|
5428
5519
|
if (this.walletAdapter) {
|
|
5429
5520
|
return this.sendViaAdapter(ethers4, abi, (iface) => {
|
|
5430
5521
|
return isCreate3 ? iface.encodeFunctionData("release", [tuple, amt, "0x"]) : iface.encodeFunctionData("release", [tuple, amt]);
|
|
@@ -5448,6 +5539,16 @@ var AdvancedEscrowClient = class {
|
|
|
5448
5539
|
*
|
|
5449
5540
|
* Calls PaymentOperator.refundInEscrow() -> escrow.partialVoid()
|
|
5450
5541
|
*
|
|
5542
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5543
|
+
* `PaymentOperator.void(paymentInfo, 0x)`, which takes no amount and returns
|
|
5544
|
+
* the WHOLE `capturableAmount`. So it first reads that amount on-chain
|
|
5545
|
+
* (`AuthCaptureEscrow.getHash` + `paymentState`) and sends only when
|
|
5546
|
+
* `amount` equals it. Otherwise nothing is sent and `errorCode` says why:
|
|
5547
|
+
* {@link ESCROW_NOTHING_TO_VOID} when it is 0,
|
|
5548
|
+
* {@link ESCROW_VOID_AMOUNT_MISMATCH} for any other amount. To return part
|
|
5549
|
+
* of an escrow on v3, `release` the part the receiver keeps, then
|
|
5550
|
+
* `refundInEscrow` what is left.
|
|
5551
|
+
*
|
|
5451
5552
|
* @param paymentInfo - PaymentInfo from the authorize step
|
|
5452
5553
|
* @param amount - Amount to refund (defaults to maxAmount)
|
|
5453
5554
|
*/
|
|
@@ -5455,10 +5556,14 @@ var AdvancedEscrowClient = class {
|
|
|
5455
5556
|
if (!this.payerAddress) await this.init();
|
|
5456
5557
|
try {
|
|
5457
5558
|
const { ethers: ethers4 } = await import('ethers');
|
|
5458
|
-
const
|
|
5559
|
+
const generation = getEscrowOperatorGeneration(this.chainId);
|
|
5560
|
+
const isCreate3 = generation === "v2";
|
|
5459
5561
|
const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
|
|
5460
5562
|
const amt = amount || paymentInfo.maxAmount;
|
|
5461
5563
|
const tuple = this.buildTuple(paymentInfo);
|
|
5564
|
+
if (generation === "v3") {
|
|
5565
|
+
return await this.voidWholeCapturable(ethers4, tuple, amt);
|
|
5566
|
+
}
|
|
5462
5567
|
if (this.walletAdapter) {
|
|
5463
5568
|
return this.sendViaAdapter(ethers4, abi, (iface) => {
|
|
5464
5569
|
return isCreate3 ? iface.encodeFunctionData("refundInEscrow", [tuple, amt, "0x"]) : iface.encodeFunctionData("refundInEscrow", [tuple, amt]);
|
|
@@ -5793,10 +5898,15 @@ var AdvancedEscrowClient = class {
|
|
|
5793
5898
|
* Calls PaymentOperator.charge() -> escrow.charge()
|
|
5794
5899
|
* Funds go directly from payer to receiver.
|
|
5795
5900
|
*
|
|
5901
|
+
* Not available on a `'v3'` operator (Arc, Arc Testnet): it returns
|
|
5902
|
+
* {@link ESCROW_UNSUPPORTED_ON_GENERATION} without signing or sending.
|
|
5903
|
+
*
|
|
5796
5904
|
* @param paymentInfo - PaymentInfo with receiver and amount
|
|
5797
5905
|
* @param amount - Amount to charge (defaults to maxAmount)
|
|
5798
5906
|
*/
|
|
5799
5907
|
async charge(paymentInfo, amount) {
|
|
5908
|
+
const unsupported = this.unsupportedOnV3("charge");
|
|
5909
|
+
if (unsupported) return unsupported;
|
|
5800
5910
|
if (!this.payerAddress) await this.init();
|
|
5801
5911
|
try {
|
|
5802
5912
|
const { ethers: ethers4 } = await import('ethers');
|
|
@@ -5857,6 +5967,11 @@ var AdvancedEscrowClient = class {
|
|
|
5857
5967
|
*
|
|
5858
5968
|
* Kept for future use when tokenCollector is implemented.
|
|
5859
5969
|
*
|
|
5970
|
+
* On a `'v3'` operator (Arc, Arc Testnet) it calls
|
|
5971
|
+
* `PaymentOperator.refund(paymentInfo, amount, tokenCollector, collectorData)`
|
|
5972
|
+
* -> escrow.refund(), the same arguments, after checking that the operator
|
|
5973
|
+
* has code ({@link ESCROW_OPERATOR_NOT_DEPLOYED}).
|
|
5974
|
+
*
|
|
5860
5975
|
* @param paymentInfo - PaymentInfo from the original authorization
|
|
5861
5976
|
* @param amount - Amount to refund (defaults to maxAmount)
|
|
5862
5977
|
* @param tokenCollector - Address of token collector for refund sourcing
|
|
@@ -5868,6 +5983,14 @@ var AdvancedEscrowClient = class {
|
|
|
5868
5983
|
const { ethers: ethers4 } = await import('ethers');
|
|
5869
5984
|
const amt = amount || paymentInfo.maxAmount;
|
|
5870
5985
|
const tuple = this.buildTuple(paymentInfo);
|
|
5986
|
+
if (getEscrowOperatorGeneration(this.chainId) === "v3") {
|
|
5987
|
+
return await this.sendV3OperatorCall(ethers4, this.v3Provider(ethers4), "refund", [
|
|
5988
|
+
tuple,
|
|
5989
|
+
amt,
|
|
5990
|
+
tokenCollector || ZERO_ADDRESS,
|
|
5991
|
+
collectorData || "0x"
|
|
5992
|
+
]);
|
|
5993
|
+
}
|
|
5871
5994
|
if (this.walletAdapter) {
|
|
5872
5995
|
return this.sendViaAdapter(ethers4, OPERATOR_ABI, (iface) => {
|
|
5873
5996
|
return iface.encodeFunctionData("refundPostEscrow", [
|
|
@@ -5898,6 +6021,89 @@ var AdvancedEscrowClient = class {
|
|
|
5898
6021
|
}
|
|
5899
6022
|
}
|
|
5900
6023
|
// ==========================================================================
|
|
6024
|
+
// INTERNAL: 'v3' operator (Arc, Arc Testnet)
|
|
6025
|
+
// ==========================================================================
|
|
6026
|
+
/** The refusal of a call a 'v3' operator does not have, or null elsewhere. */
|
|
6027
|
+
unsupportedOnV3(method) {
|
|
6028
|
+
if (getEscrowOperatorGeneration(this.chainId) !== "v3") return null;
|
|
6029
|
+
return {
|
|
6030
|
+
success: false,
|
|
6031
|
+
errorCode: ESCROW_UNSUPPORTED_ON_GENERATION,
|
|
6032
|
+
error: `${method} is not available on the v3 escrow operator of chain ${this.chainId} (OPERATOR_ABI_V3). Nothing was signed or sent.`
|
|
6033
|
+
};
|
|
6034
|
+
}
|
|
6035
|
+
/** The provider a 'v3' call reads with before it sends anything. */
|
|
6036
|
+
v3Provider(ethersModule) {
|
|
6037
|
+
const provider = this.walletAdapter ? new ethersModule.JsonRpcProvider(this.rpcUrl) : this.signer?.provider;
|
|
6038
|
+
if (!provider) {
|
|
6039
|
+
throw new Error(
|
|
6040
|
+
`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.`
|
|
6041
|
+
);
|
|
6042
|
+
}
|
|
6043
|
+
return provider;
|
|
6044
|
+
}
|
|
6045
|
+
/**
|
|
6046
|
+
* Send one OPERATOR_ABI_V3 call, once the operator is known to have code.
|
|
6047
|
+
* A call to an address with no code succeeds and moves nothing, and would be
|
|
6048
|
+
* reported as a success.
|
|
6049
|
+
*/
|
|
6050
|
+
async sendV3OperatorCall(ethersModule, provider, method, args) {
|
|
6051
|
+
const code = await provider.getCode(this.contracts.operator);
|
|
6052
|
+
if (!code || code === "0x") {
|
|
6053
|
+
return {
|
|
6054
|
+
success: false,
|
|
6055
|
+
errorCode: ESCROW_OPERATOR_NOT_DEPLOYED,
|
|
6056
|
+
error: `The escrow operator ${this.contracts.operator} has no code on chain ${this.chainId}. Nothing was sent.`
|
|
6057
|
+
};
|
|
6058
|
+
}
|
|
6059
|
+
if (this.walletAdapter) {
|
|
6060
|
+
return await this.sendViaAdapter(
|
|
6061
|
+
ethersModule,
|
|
6062
|
+
OPERATOR_ABI_V3,
|
|
6063
|
+
(iface) => iface.encodeFunctionData(method, args)
|
|
6064
|
+
);
|
|
6065
|
+
}
|
|
6066
|
+
const contract = new ethersModule.Contract(this.contracts.operator, OPERATOR_ABI_V3, this.signer);
|
|
6067
|
+
const tx = await contract.getFunction(method)(...args, { gasLimit: this.gasLimit });
|
|
6068
|
+
const receipt = await tx.wait();
|
|
6069
|
+
return {
|
|
6070
|
+
success: receipt.status === 1,
|
|
6071
|
+
transactionHash: receipt.hash,
|
|
6072
|
+
gasUsed: Number(receipt.gasUsed),
|
|
6073
|
+
error: receipt.status !== 1 ? "Transaction reverted" : void 0
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
/**
|
|
6077
|
+
* `refundInEscrow` on a 'v3' operator: `void` returns the whole capturable
|
|
6078
|
+
* amount, so it is sent only when that is exactly what was asked for.
|
|
6079
|
+
*/
|
|
6080
|
+
async voidWholeCapturable(ethersModule, tuple, amount) {
|
|
6081
|
+
const requested = BigInt(amount);
|
|
6082
|
+
if (requested <= 0n) {
|
|
6083
|
+
return { success: false, error: `refundInEscrow amount must be positive, got ${amount}. Nothing was sent.` };
|
|
6084
|
+
}
|
|
6085
|
+
const provider = this.v3Provider(ethersModule);
|
|
6086
|
+
const escrow = new ethersModule.Contract(this.contracts.escrow, AUTH_CAPTURE_ESCROW_STATE_ABI, provider);
|
|
6087
|
+
const paymentInfoHash = await escrow.getHash(tuple);
|
|
6088
|
+
const [, capturable] = await escrow.paymentState(paymentInfoHash);
|
|
6089
|
+
const capturableAmount = BigInt(capturable);
|
|
6090
|
+
if (capturableAmount === 0n) {
|
|
6091
|
+
return {
|
|
6092
|
+
success: false,
|
|
6093
|
+
errorCode: ESCROW_NOTHING_TO_VOID,
|
|
6094
|
+
error: `Nothing to void on chain ${this.chainId}: capturableAmount is 0 for payment ${paymentInfoHash}. Nothing was sent.`
|
|
6095
|
+
};
|
|
6096
|
+
}
|
|
6097
|
+
if (requested !== capturableAmount) {
|
|
6098
|
+
return {
|
|
6099
|
+
success: false,
|
|
6100
|
+
errorCode: ESCROW_VOID_AMOUNT_MISMATCH,
|
|
6101
|
+
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.`
|
|
6102
|
+
};
|
|
6103
|
+
}
|
|
6104
|
+
return await this.sendV3OperatorCall(ethersModule, provider, "void", [tuple, "0x"]);
|
|
6105
|
+
}
|
|
6106
|
+
// ==========================================================================
|
|
5901
6107
|
// INTERNAL: Adapter-based transaction signing and broadcast
|
|
5902
6108
|
// ==========================================================================
|
|
5903
6109
|
/**
|
|
@@ -5941,6 +6147,6 @@ var AdvancedEscrowClient = class {
|
|
|
5941
6147
|
}
|
|
5942
6148
|
};
|
|
5943
6149
|
|
|
5944
|
-
export { AMBIGUOUS_LEASE_REASONS, AUTHORIZATION_ALREADY_SETTLED, AUTHORIZATION_IN_FLIGHT, AdvancedEscrowClient, BASE_MAINNET_CONTRACTS, BazaarClient, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, DEPOSIT_LIMIT_USDC, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, Erc8004LookupError, EscrowClient, FacilitatorClient, HEALTH_FILTERS, IDEMPOTENCY_KEY_HEADER, IDEMPOTENT_REPLAYED_HEADER, MAX_RETRY_AFTER_SECONDS, MAX_SEARCH_LEN, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, RECEIPT_ISSUER, RECEIPT_REQUEST_CONFLICT, RELAYED_FEEDBACK_NETWORKS, REPLAYABLE_LEASE_REASONS, RegistrationPendingError, SETTLEMENT_UNCONFIRMED, SOLANA_FEEDBACK_NETWORKS, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, WRITER_LEASE_REASONS, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentConflictResponse, buildPaymentRequirements, buildSettleRequest, buildSettleRequestForVersion, buildSettleRequestV2, buildUnavailableResponse, buildVerifyRequest, buildVerifyRequestForVersion, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, canonicalReceiptJson, carryFailureFields, create402Response, createHonoMiddleware, createIdempotencyKey, createPaymentMiddleware, createPurchaseContext, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, facilitatorFetch, fetchWithReceipt, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, getFacilitatorReceipt, isAlive, isAmbiguousLeaseReason, isAuthorizationAlreadyUsed, isAuthorizationInFlight, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, isReplayableLeaseReason, isSettlementUnconfirmed, mergeHeaderList, mergePaymentResponseHeaders, parseFacilitatorErrorBody, parseFacilitatorReceipt, parsePaymentHeader, parseRetryAfterSeconds, paymentResponseHeaders, purchaseContextHeader, readFacilitatorError, receiptCommitment, receiptFromErrorBody, receiptFromResponse, resolveEnvelopeVersion, supportsRelayedFeedback, supportsSolanaFeedback, toPaymentRequirementsV2, toResourceInfoV2, validatePurchaseContext, verifyFacilitatorReceipt, wireNetwork };
|
|
6150
|
+
export { AMBIGUOUS_LEASE_REASONS, AUTHORIZATION_ALREADY_SETTLED, AUTHORIZATION_IN_FLIGHT, AdvancedEscrowClient, BASE_MAINNET_CONTRACTS, BazaarClient, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, DEPOSIT_LIMIT_USDC, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_NOTHING_TO_VOID, ESCROW_OPERATOR_GENERATION, ESCROW_OPERATOR_NOT_DEPLOYED, ESCROW_TIMEOUT_MS, ESCROW_UNSUPPORTED_ON_GENERATION, ESCROW_VOID_AMOUNT_MISMATCH, Erc8004Client, Erc8004LookupError, EscrowClient, FacilitatorClient, HEALTH_FILTERS, IDEMPOTENCY_KEY_HEADER, IDEMPOTENT_REPLAYED_HEADER, MAX_RETRY_AFTER_SECONDS, MAX_SEARCH_LEN, OPERATOR_ABI, OPERATOR_ABI_CREATE3, OPERATOR_ABI_V3, PAYMENT_INFO_TYPEHASH, RECEIPT_ISSUER, RECEIPT_REQUEST_CONFLICT, RELAYED_FEEDBACK_NETWORKS, REPLAYABLE_LEASE_REASONS, RegistrationPendingError, SETTLEMENT_UNCONFIRMED, SOLANA_FEEDBACK_NETWORKS, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, WRITER_LEASE_REASONS, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentConflictResponse, buildPaymentRequirements, buildSettleRequest, buildSettleRequestForVersion, buildSettleRequestV2, buildUnavailableResponse, buildVerifyRequest, buildVerifyRequestForVersion, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, canonicalReceiptJson, carryFailureFields, create402Response, createHonoMiddleware, createIdempotencyKey, createPaymentMiddleware, createPurchaseContext, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, facilitatorFetch, fetchWithReceipt, getCorsHeaders, getEscrowContractsByChainId, getEscrowOperatorGeneration, getEscrowSupportedChainIds, getFacilitatorReceipt, isAlive, isAmbiguousLeaseReason, isAuthorizationAlreadyUsed, isAuthorizationInFlight, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, isReplayableLeaseReason, isSettlementUnconfirmed, mergeHeaderList, mergePaymentResponseHeaders, parseFacilitatorErrorBody, parseFacilitatorReceipt, parsePaymentHeader, parseRetryAfterSeconds, paymentResponseHeaders, purchaseContextHeader, readFacilitatorError, receiptCommitment, receiptFromErrorBody, receiptFromResponse, resolveEnvelopeVersion, supportsRelayedFeedback, supportsSolanaFeedback, toPaymentRequirementsV2, toResourceInfoV2, validatePurchaseContext, verifyFacilitatorReceipt, wireNetwork };
|
|
5945
6151
|
//# sourceMappingURL=index.mjs.map
|
|
5946
6152
|
//# sourceMappingURL=index.mjs.map
|