uvd-x402-sdk 2.85.0 → 2.86.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.
@@ -1,4 +1,4 @@
1
- import 'ethers';
1
+ import { ethers } from 'ethers';
2
2
 
3
3
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
4
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -46,6 +46,19 @@ var CAIP2_IDENTIFIERS = {
46
46
  var CAIP2_TO_CHAIN = Object.fromEntries(
47
47
  Object.entries(CAIP2_IDENTIFIERS).map(([k, v]) => [v, k])
48
48
  );
49
+ var X402Error = class _X402Error extends Error {
50
+ code;
51
+ details;
52
+ constructor(message, code, details) {
53
+ super(message);
54
+ this.name = "X402Error";
55
+ this.code = code;
56
+ this.details = details;
57
+ if (Error.captureStackTrace) {
58
+ Error.captureStackTrace(this, _X402Error);
59
+ }
60
+ }
61
+ };
49
62
 
50
63
  // src/chains/index.ts
51
64
  var DEFAULT_FACILITATOR_URL = "https://facilitator.ultravioletadao.xyz";
@@ -1113,6 +1126,188 @@ var DEFAULT_MIN_FEE_BPS = 0;
1113
1126
  var DEFAULT_MAX_FEE_BPS = OPERATOR_FEE_BPS + MAX_PROTOCOL_FEE_BPS;
1114
1127
  var REVIEW_WINDOW_SEC = 7 * 24 * 3600;
1115
1128
  var REFUND_WINDOW_SEC = 7 * 24 * 3600;
1129
+ var LIFECYCLE_DOMAIN_NAME = "x402 escrow lifecycle";
1130
+ var LIFECYCLE_DOMAIN_VERSION = "1";
1131
+ var LIFECYCLE_MAX_DEADLINE_SECS = 900;
1132
+ var LIFECYCLE_DEFAULT_DEADLINE_SECS = 600;
1133
+ var LIFECYCLE_ACTIONS = ["release", "refundInEscrow"];
1134
+ var LIFECYCLE_ORDER_TYPES = {
1135
+ LifecycleOrder: [
1136
+ { name: "action", type: "string" },
1137
+ { name: "amount", type: "uint256" },
1138
+ { name: "deadline", type: "uint256" },
1139
+ { name: "nonce", type: "bytes32" },
1140
+ { name: "paymentInfo", type: "PaymentInfo" }
1141
+ ],
1142
+ PaymentInfo: [
1143
+ { name: "operator", type: "address" },
1144
+ { name: "payer", type: "address" },
1145
+ { name: "receiver", type: "address" },
1146
+ { name: "token", type: "address" },
1147
+ { name: "maxAmount", type: "uint120" },
1148
+ { name: "preApprovalExpiry", type: "uint48" },
1149
+ { name: "authorizationExpiry", type: "uint48" },
1150
+ { name: "refundExpiry", type: "uint48" },
1151
+ { name: "minFeeBps", type: "uint16" },
1152
+ { name: "maxFeeBps", type: "uint16" },
1153
+ { name: "feeReceiver", type: "address" },
1154
+ { name: "salt", type: "uint256" }
1155
+ ]
1156
+ };
1157
+ var LIFECYCLE_PI_KEYS = [
1158
+ "operator",
1159
+ "receiver",
1160
+ "token",
1161
+ "maxAmount",
1162
+ "preApprovalExpiry",
1163
+ "authorizationExpiry",
1164
+ "refundExpiry",
1165
+ "minFeeBps",
1166
+ "maxFeeBps",
1167
+ "feeReceiver",
1168
+ "salt"
1169
+ ];
1170
+ function saltToBigInt(salt) {
1171
+ if (typeof salt === "bigint") return salt;
1172
+ if (typeof salt === "number") {
1173
+ if (!Number.isInteger(salt) || salt < 0) {
1174
+ throw new X402Error(`paymentInfo.salt invalid: ${String(salt)}`, "INVALID_CONFIG");
1175
+ }
1176
+ return BigInt(salt);
1177
+ }
1178
+ if (typeof salt === "string") {
1179
+ const trimmed = salt.trim();
1180
+ const hex = trimmed.startsWith("0x") || trimmed.startsWith("0X") ? trimmed : `0x${trimmed}`;
1181
+ try {
1182
+ return BigInt(hex);
1183
+ } catch {
1184
+ throw new X402Error(`paymentInfo.salt invalid: ${salt}`, "INVALID_CONFIG");
1185
+ }
1186
+ }
1187
+ throw new X402Error(`paymentInfo.salt invalid: ${String(salt)}`, "INVALID_CONFIG");
1188
+ }
1189
+ function nonceToBytes32(nonce) {
1190
+ if (typeof nonce !== "string") {
1191
+ throw new X402Error(`lifecycleAuth.nonce invalid: ${String(nonce)}`, "INVALID_CONFIG");
1192
+ }
1193
+ const raw = nonce.startsWith("0x") || nonce.startsWith("0X") ? nonce.slice(2) : nonce;
1194
+ if (!/^[0-9a-fA-F]*$/.test(raw)) {
1195
+ throw new X402Error(`lifecycleAuth.nonce is not hex: ${nonce}`, "INVALID_CONFIG");
1196
+ }
1197
+ if (raw.length !== 64) {
1198
+ throw new X402Error(
1199
+ `lifecycleAuth.nonce must be 32 bytes, got ${raw.length / 2}`,
1200
+ "INVALID_CONFIG"
1201
+ );
1202
+ }
1203
+ return `0x${raw.toLowerCase()}`;
1204
+ }
1205
+ function randomNonce() {
1206
+ const webCrypto = globalThis.crypto;
1207
+ if (webCrypto?.getRandomValues) {
1208
+ const bytes = new Uint8Array(32);
1209
+ webCrypto.getRandomValues(bytes);
1210
+ return ethers.hexlify(bytes);
1211
+ }
1212
+ return ethers.hexlify(ethers.randomBytes(32));
1213
+ }
1214
+ function toUintString(value, field) {
1215
+ let n;
1216
+ try {
1217
+ n = typeof value === "bigint" ? value : BigInt(value);
1218
+ } catch {
1219
+ throw new X402Error(`${field} must be a non-negative integer, got ${String(value)}`, "INVALID_CONFIG");
1220
+ }
1221
+ if (n < 0n) {
1222
+ throw new X402Error(`${field} must be a non-negative integer, got ${String(value)}`, "INVALID_CONFIG");
1223
+ }
1224
+ return n.toString();
1225
+ }
1226
+ function buildLifecycleTypedData(params) {
1227
+ const { action, paymentInfo, payer, amount, chainId, deadline, nonce } = params;
1228
+ if (!LIFECYCLE_ACTIONS.includes(action)) {
1229
+ throw new X402Error(
1230
+ `unknown lifecycle action ${String(action)}; the facilitator only signs ${LIFECYCLE_ACTIONS.join(", ")}`,
1231
+ "INVALID_CONFIG"
1232
+ );
1233
+ }
1234
+ let amountBig;
1235
+ try {
1236
+ amountBig = typeof amount === "bigint" ? amount : BigInt(amount);
1237
+ } catch {
1238
+ throw new X402Error(`amount must be an integer >= 0, got ${String(amount)}`, "INVALID_AMOUNT");
1239
+ }
1240
+ if (amountBig < 0n) {
1241
+ throw new X402Error(`amount must be an integer >= 0, got ${String(amount)}`, "INVALID_AMOUNT");
1242
+ }
1243
+ const pi = paymentInfo ?? {};
1244
+ const missing = LIFECYCLE_PI_KEYS.filter((k) => pi[k] === void 0);
1245
+ if (missing.length > 0) {
1246
+ throw new X402Error(
1247
+ `paymentInfo is missing fields that enter the signature: ${missing.join(", ")}. The paymentInfo that is SENT is the one that is signed; defaulting a field would sign a different struct than the one that reaches the facilitator.`,
1248
+ "INVALID_CONFIG"
1249
+ );
1250
+ }
1251
+ return {
1252
+ domain: {
1253
+ name: LIFECYCLE_DOMAIN_NAME,
1254
+ version: LIFECYCLE_DOMAIN_VERSION,
1255
+ chainId: Number(chainId)
1256
+ },
1257
+ types: LIFECYCLE_ORDER_TYPES,
1258
+ primaryType: "LifecycleOrder",
1259
+ message: {
1260
+ action,
1261
+ amount: amountBig.toString(),
1262
+ deadline: toUintString(deadline, "deadline"),
1263
+ nonce: nonceToBytes32(nonce),
1264
+ paymentInfo: {
1265
+ operator: ethers.getAddress(paymentInfo.operator),
1266
+ payer: ethers.getAddress(payer),
1267
+ receiver: ethers.getAddress(paymentInfo.receiver),
1268
+ token: ethers.getAddress(paymentInfo.token),
1269
+ maxAmount: toUintString(paymentInfo.maxAmount, "paymentInfo.maxAmount"),
1270
+ preApprovalExpiry: toUintString(paymentInfo.preApprovalExpiry, "paymentInfo.preApprovalExpiry"),
1271
+ authorizationExpiry: toUintString(
1272
+ paymentInfo.authorizationExpiry,
1273
+ "paymentInfo.authorizationExpiry"
1274
+ ),
1275
+ refundExpiry: toUintString(paymentInfo.refundExpiry, "paymentInfo.refundExpiry"),
1276
+ minFeeBps: toUintString(paymentInfo.minFeeBps, "paymentInfo.minFeeBps"),
1277
+ maxFeeBps: toUintString(paymentInfo.maxFeeBps, "paymentInfo.maxFeeBps"),
1278
+ feeReceiver: ethers.getAddress(paymentInfo.feeReceiver),
1279
+ // uint256 in the signature, bytes32 on the wire — see saltToBigInt.
1280
+ salt: saltToBigInt(paymentInfo.salt).toString()
1281
+ }
1282
+ }
1283
+ };
1284
+ }
1285
+ async function buildLifecycleAuth(params) {
1286
+ const { wallet, deadline, nonce, now, ...rest } = params;
1287
+ const nowSec = now === void 0 ? Math.floor(Date.now() / 1e3) : Math.floor(now);
1288
+ const dl = deadline === void 0 ? nowSec + LIFECYCLE_DEFAULT_DEADLINE_SECS : Math.floor(deadline);
1289
+ const nonceHex = nonce === void 0 ? randomNonce() : nonce;
1290
+ if (dl < nowSec) {
1291
+ throw new X402Error(
1292
+ `deadline ${dl} is in the past (now ${nowSec}): the facilitator discards it as \`expired\``,
1293
+ "INVALID_CONFIG"
1294
+ );
1295
+ }
1296
+ if (dl - nowSec > LIFECYCLE_MAX_DEADLINE_SECS) {
1297
+ throw new X402Error(
1298
+ `deadline ${dl} is ${dl - nowSec} s ahead and the facilitator's ceiling is ${LIFECYCLE_MAX_DEADLINE_SECS} s (\`deadline_too_far\`): a leaked order cannot be a standing permission`,
1299
+ "INVALID_CONFIG"
1300
+ );
1301
+ }
1302
+ const typed = buildLifecycleTypedData({ ...rest, deadline: dl, nonce: nonceHex });
1303
+ const signed = await wallet.signTypedData(JSON.stringify(typed));
1304
+ return {
1305
+ signer: wallet.getAddress(),
1306
+ deadline: dl,
1307
+ nonce: nonceToBytes32(nonceHex),
1308
+ signature: signed.signature
1309
+ };
1310
+ }
1116
1311
 
1117
1312
  // src/backend/facilitator-error.ts
1118
1313
  var WRITER_LEASE_REASONS = [
@@ -4202,8 +4397,8 @@ var AdvancedEscrowClient = class {
4202
4397
  * Matches the on-chain AuthCaptureEscrow nonce derivation.
4203
4398
  */
4204
4399
  async computeNonce(paymentInfo) {
4205
- const { ethers: ethers3 } = await import('ethers');
4206
- const piTuple = ethers3.AbiCoder.defaultAbiCoder().encode(
4400
+ const { ethers: ethers4 } = await import('ethers');
4401
+ const piTuple = ethers4.AbiCoder.defaultAbiCoder().encode(
4207
4402
  ["bytes32", "tuple(address,address,address,address,uint120,uint48,uint48,uint48,uint16,uint16,address,uint256)"],
4208
4403
  [
4209
4404
  PAYMENT_INFO_TYPEHASH,
@@ -4224,12 +4419,12 @@ var AdvancedEscrowClient = class {
4224
4419
  ]
4225
4420
  ]
4226
4421
  );
4227
- const piHash = ethers3.keccak256(piTuple);
4228
- const finalEncoded = ethers3.AbiCoder.defaultAbiCoder().encode(
4422
+ const piHash = ethers4.keccak256(piTuple);
4423
+ const finalEncoded = ethers4.AbiCoder.defaultAbiCoder().encode(
4229
4424
  ["uint256", "address", "bytes32"],
4230
4425
  [this.chainId, this.contracts.escrow, piHash]
4231
4426
  );
4232
- return ethers3.keccak256(finalEncoded);
4427
+ return ethers4.keccak256(finalEncoded);
4233
4428
  }
4234
4429
  /**
4235
4430
  * Sign ReceiveWithAuthorization for ERC-3009.
@@ -4386,17 +4581,17 @@ var AdvancedEscrowClient = class {
4386
4581
  async release(paymentInfo, amount) {
4387
4582
  if (!this.payerAddress) await this.init();
4388
4583
  try {
4389
- const { ethers: ethers3 } = await import('ethers');
4584
+ const { ethers: ethers4 } = await import('ethers');
4390
4585
  const isCreate3 = CREATE3_CHAIN_IDS.has(this.chainId);
4391
4586
  const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
4392
4587
  const amt = amount || paymentInfo.maxAmount;
4393
4588
  const tuple = this.buildTuple(paymentInfo);
4394
4589
  if (this.walletAdapter) {
4395
- return this.sendViaAdapter(ethers3, abi, (iface) => {
4590
+ return this.sendViaAdapter(ethers4, abi, (iface) => {
4396
4591
  return isCreate3 ? iface.encodeFunctionData("release", [tuple, amt, "0x"]) : iface.encodeFunctionData("release", [tuple, amt]);
4397
4592
  });
4398
4593
  }
4399
- const contract = new ethers3.Contract(this.contracts.operator, abi, this.signer);
4594
+ const contract = new ethers4.Contract(this.contracts.operator, abi, this.signer);
4400
4595
  const tx = isCreate3 ? await contract.release(tuple, amt, "0x", { gasLimit: this.gasLimit }) : await contract.release(tuple, amt, { gasLimit: this.gasLimit });
4401
4596
  const receipt = await tx.wait();
4402
4597
  return {
@@ -4420,17 +4615,17 @@ var AdvancedEscrowClient = class {
4420
4615
  async refundInEscrow(paymentInfo, amount) {
4421
4616
  if (!this.payerAddress) await this.init();
4422
4617
  try {
4423
- const { ethers: ethers3 } = await import('ethers');
4618
+ const { ethers: ethers4 } = await import('ethers');
4424
4619
  const isCreate3 = CREATE3_CHAIN_IDS.has(this.chainId);
4425
4620
  const abi = isCreate3 ? OPERATOR_ABI_CREATE3 : OPERATOR_ABI;
4426
4621
  const amt = amount || paymentInfo.maxAmount;
4427
4622
  const tuple = this.buildTuple(paymentInfo);
4428
4623
  if (this.walletAdapter) {
4429
- return this.sendViaAdapter(ethers3, abi, (iface) => {
4624
+ return this.sendViaAdapter(ethers4, abi, (iface) => {
4430
4625
  return isCreate3 ? iface.encodeFunctionData("refundInEscrow", [tuple, amt, "0x"]) : iface.encodeFunctionData("refundInEscrow", [tuple, amt]);
4431
4626
  });
4432
4627
  }
4433
- const contract = new ethers3.Contract(this.contracts.operator, abi, this.signer);
4628
+ const contract = new ethers4.Contract(this.contracts.operator, abi, this.signer);
4434
4629
  const tx = isCreate3 ? await contract.refundInEscrow(tuple, amt, "0x", { gasLimit: this.gasLimit }) : await contract.refundInEscrow(tuple, amt, { gasLimit: this.gasLimit });
4435
4630
  const receipt = await tx.wait();
4436
4631
  return {
@@ -4465,30 +4660,49 @@ var AdvancedEscrowClient = class {
4465
4660
  * const result = await client.releaseViaFacilitator(pi);
4466
4661
  * console.log(result.transactionHash);
4467
4662
  * ```
4663
+ *
4664
+ * @example Signed release (the payer proves the release is theirs to ask for)
4665
+ * ```typescript
4666
+ * await client.releaseViaFacilitator(pi, undefined, {
4667
+ * lifecycleSigner: payerWallet, // EnvKeyAdapter, OWS, wagmiLifecycleSigner(...)
4668
+ * });
4669
+ * ```
4468
4670
  */
4469
- async releaseViaFacilitator(paymentInfo, amount) {
4671
+ async releaseViaFacilitator(paymentInfo, amount, options) {
4470
4672
  if (!this.payerAddress) await this.init();
4471
4673
  try {
4674
+ const wirePaymentInfo = {
4675
+ operator: paymentInfo.operator,
4676
+ receiver: paymentInfo.receiver,
4677
+ token: paymentInfo.token,
4678
+ maxAmount: paymentInfo.maxAmount,
4679
+ preApprovalExpiry: paymentInfo.preApprovalExpiry,
4680
+ authorizationExpiry: paymentInfo.authorizationExpiry,
4681
+ refundExpiry: paymentInfo.refundExpiry,
4682
+ minFeeBps: paymentInfo.minFeeBps,
4683
+ maxFeeBps: paymentInfo.maxFeeBps,
4684
+ feeReceiver: paymentInfo.feeReceiver,
4685
+ salt: paymentInfo.salt
4686
+ };
4687
+ const releaseAmount = amount || paymentInfo.maxAmount;
4688
+ const lifecycleAuth = options?.lifecycleSigner ? await buildLifecycleAuth({
4689
+ action: "release",
4690
+ paymentInfo: wirePaymentInfo,
4691
+ payer: this.payerAddress,
4692
+ amount: releaseAmount,
4693
+ chainId: this.chainId,
4694
+ wallet: options.lifecycleSigner,
4695
+ deadline: options.lifecycleDeadline
4696
+ }) : void 0;
4472
4697
  const payload = {
4473
4698
  x402Version: 2,
4474
4699
  scheme: "escrow",
4475
4700
  action: "release",
4476
4701
  payload: {
4477
- paymentInfo: {
4478
- operator: paymentInfo.operator,
4479
- receiver: paymentInfo.receiver,
4480
- token: paymentInfo.token,
4481
- maxAmount: paymentInfo.maxAmount,
4482
- preApprovalExpiry: paymentInfo.preApprovalExpiry,
4483
- authorizationExpiry: paymentInfo.authorizationExpiry,
4484
- refundExpiry: paymentInfo.refundExpiry,
4485
- minFeeBps: paymentInfo.minFeeBps,
4486
- maxFeeBps: paymentInfo.maxFeeBps,
4487
- feeReceiver: paymentInfo.feeReceiver,
4488
- salt: paymentInfo.salt
4489
- },
4702
+ paymentInfo: wirePaymentInfo,
4490
4703
  payer: this.payerAddress,
4491
- amount: amount || paymentInfo.maxAmount
4704
+ amount: releaseAmount,
4705
+ ...lifecycleAuth ? { lifecycleAuth } : {}
4492
4706
  },
4493
4707
  paymentRequirements: {
4494
4708
  scheme: "escrow",
@@ -4591,29 +4805,41 @@ var AdvancedEscrowClient = class {
4591
4805
  * }
4592
4806
  * ```
4593
4807
  */
4594
- async refundViaFacilitator(paymentInfo, amount) {
4808
+ async refundViaFacilitator(paymentInfo, amount, options) {
4595
4809
  if (!this.payerAddress) await this.init();
4596
4810
  try {
4811
+ const wirePaymentInfo = {
4812
+ operator: paymentInfo.operator,
4813
+ receiver: paymentInfo.receiver,
4814
+ token: paymentInfo.token,
4815
+ maxAmount: paymentInfo.maxAmount,
4816
+ preApprovalExpiry: paymentInfo.preApprovalExpiry,
4817
+ authorizationExpiry: paymentInfo.authorizationExpiry,
4818
+ refundExpiry: paymentInfo.refundExpiry,
4819
+ minFeeBps: paymentInfo.minFeeBps,
4820
+ maxFeeBps: paymentInfo.maxFeeBps,
4821
+ feeReceiver: paymentInfo.feeReceiver,
4822
+ salt: paymentInfo.salt
4823
+ };
4824
+ const refundAmount = amount || paymentInfo.maxAmount;
4825
+ const lifecycleAuth = options?.lifecycleSigner ? await buildLifecycleAuth({
4826
+ action: "refundInEscrow",
4827
+ paymentInfo: wirePaymentInfo,
4828
+ payer: this.payerAddress,
4829
+ amount: refundAmount,
4830
+ chainId: this.chainId,
4831
+ wallet: options.lifecycleSigner,
4832
+ deadline: options.lifecycleDeadline
4833
+ }) : void 0;
4597
4834
  const payload = {
4598
4835
  x402Version: 2,
4599
4836
  scheme: "escrow",
4600
4837
  action: "refundInEscrow",
4601
4838
  payload: {
4602
- paymentInfo: {
4603
- operator: paymentInfo.operator,
4604
- receiver: paymentInfo.receiver,
4605
- token: paymentInfo.token,
4606
- maxAmount: paymentInfo.maxAmount,
4607
- preApprovalExpiry: paymentInfo.preApprovalExpiry,
4608
- authorizationExpiry: paymentInfo.authorizationExpiry,
4609
- refundExpiry: paymentInfo.refundExpiry,
4610
- minFeeBps: paymentInfo.minFeeBps,
4611
- maxFeeBps: paymentInfo.maxFeeBps,
4612
- feeReceiver: paymentInfo.feeReceiver,
4613
- salt: paymentInfo.salt
4614
- },
4839
+ paymentInfo: wirePaymentInfo,
4615
4840
  payer: this.payerAddress,
4616
- amount: amount || paymentInfo.maxAmount
4841
+ amount: refundAmount,
4842
+ ...lifecycleAuth ? { lifecycleAuth } : {}
4617
4843
  },
4618
4844
  paymentRequirements: {
4619
4845
  scheme: "escrow",
@@ -4733,7 +4959,7 @@ var AdvancedEscrowClient = class {
4733
4959
  async charge(paymentInfo, amount) {
4734
4960
  if (!this.payerAddress) await this.init();
4735
4961
  try {
4736
- const { ethers: ethers3 } = await import('ethers');
4962
+ const { ethers: ethers4 } = await import('ethers');
4737
4963
  const nonce = await this.computeNonce(paymentInfo);
4738
4964
  const amt = amount || paymentInfo.maxAmount;
4739
4965
  const auth = {
@@ -4745,10 +4971,10 @@ var AdvancedEscrowClient = class {
4745
4971
  nonce
4746
4972
  };
4747
4973
  const signature = await this.signErc3009(auth);
4748
- const collectorData = ethers3.getBytes(signature);
4974
+ const collectorData = ethers4.getBytes(signature);
4749
4975
  const tuple = this.buildTuple(paymentInfo);
4750
4976
  if (this.walletAdapter) {
4751
- return this.sendViaAdapter(ethers3, OPERATOR_ABI, (iface) => {
4977
+ return this.sendViaAdapter(ethers4, OPERATOR_ABI, (iface) => {
4752
4978
  return iface.encodeFunctionData("charge", [
4753
4979
  tuple,
4754
4980
  amt,
@@ -4757,7 +4983,7 @@ var AdvancedEscrowClient = class {
4757
4983
  ]);
4758
4984
  });
4759
4985
  }
4760
- const contract = new ethers3.Contract(this.contracts.operator, OPERATOR_ABI, this.signer);
4986
+ const contract = new ethers4.Contract(this.contracts.operator, OPERATOR_ABI, this.signer);
4761
4987
  const tx = await contract.charge(
4762
4988
  tuple,
4763
4989
  amt,
@@ -4799,11 +5025,11 @@ var AdvancedEscrowClient = class {
4799
5025
  async refundPostEscrow(paymentInfo, amount, tokenCollector, collectorData) {
4800
5026
  if (!this.payerAddress) await this.init();
4801
5027
  try {
4802
- const { ethers: ethers3 } = await import('ethers');
5028
+ const { ethers: ethers4 } = await import('ethers');
4803
5029
  const amt = amount || paymentInfo.maxAmount;
4804
5030
  const tuple = this.buildTuple(paymentInfo);
4805
5031
  if (this.walletAdapter) {
4806
- return this.sendViaAdapter(ethers3, OPERATOR_ABI, (iface) => {
5032
+ return this.sendViaAdapter(ethers4, OPERATOR_ABI, (iface) => {
4807
5033
  return iface.encodeFunctionData("refundPostEscrow", [
4808
5034
  tuple,
4809
5035
  amt,
@@ -4812,7 +5038,7 @@ var AdvancedEscrowClient = class {
4812
5038
  ]);
4813
5039
  });
4814
5040
  }
4815
- const contract = new ethers3.Contract(this.contracts.operator, OPERATOR_ABI, this.signer);
5041
+ const contract = new ethers4.Contract(this.contracts.operator, OPERATOR_ABI, this.signer);
4816
5042
  const tx = await contract.refundPostEscrow(
4817
5043
  tuple,
4818
5044
  amt,