@provex/react 1.9.2-rc.20260725134754.714d99f → 1.9.2-rc.20260725154152.dfd6bd9
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/{chunk-UL3B2WE2.js → chunk-LBZZ7TJT.js} +71 -23
- package/dist/chunk-LBZZ7TJT.js.map +1 -0
- package/dist/index.cjs +67 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +2 -2
- package/dist/wagmi.cjs +67 -19
- package/dist/wagmi.cjs.map +1 -1
- package/dist/wagmi.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-UL3B2WE2.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var reputation = require('@provex/utils/reputation');
|
|
|
13
13
|
var contracts = require('@provex/utils/contracts');
|
|
14
14
|
var proving = require('@provex/proving');
|
|
15
15
|
var utils = require('@provex/utils');
|
|
16
|
+
var deposit = require('@provex/utils/deposit');
|
|
16
17
|
var fees = require('@provex/utils/fees');
|
|
17
18
|
var abis = require('@provex/abis');
|
|
18
19
|
var chain = require('@provex/utils/chain');
|
|
@@ -384,82 +385,85 @@ var ProveXClient = class {
|
|
|
384
385
|
this.onSlowSync = config.onSlowSync;
|
|
385
386
|
this.apiUrl = config.apiUrl ?? defaults?.apiUrl ?? "https://app.provex.com";
|
|
386
387
|
this.createDepositRaw = this.buildWritableMethod({
|
|
387
|
-
abi:
|
|
388
|
+
abi: () => this.getEscrowAbi(),
|
|
388
389
|
contractResolver: () => this.getEscrowAddress(),
|
|
389
390
|
functionName: "createDeposit",
|
|
390
|
-
argsMapper: (params) => [
|
|
391
|
+
argsMapper: (params) => [{
|
|
392
|
+
...params,
|
|
393
|
+
currencies: params.currencies.map((perMethod) => deposit.toEscrowCurrencies(perMethod, this.getEscrowGeneration()))
|
|
394
|
+
}]
|
|
391
395
|
});
|
|
392
396
|
this.addFunds = this.buildWritableMethod({
|
|
393
|
-
abi:
|
|
397
|
+
abi: () => this.getEscrowAbi(),
|
|
394
398
|
contractResolver: () => this.getEscrowAddress(),
|
|
395
399
|
functionName: "addFunds",
|
|
396
400
|
argsMapper: (params) => [params.depositId, params.amount]
|
|
397
401
|
});
|
|
398
402
|
this.removeFunds = this.buildWritableMethod({
|
|
399
|
-
abi:
|
|
403
|
+
abi: () => this.getEscrowAbi(),
|
|
400
404
|
contractResolver: () => this.getEscrowAddress(),
|
|
401
405
|
functionName: "removeFunds",
|
|
402
406
|
argsMapper: (params) => [params.depositId, params.amount]
|
|
403
407
|
});
|
|
404
408
|
this.withdrawDeposit = this.buildWritableMethod({
|
|
405
|
-
abi:
|
|
409
|
+
abi: () => this.getEscrowAbi(),
|
|
406
410
|
contractResolver: () => this.getEscrowAddress(),
|
|
407
411
|
functionName: "withdrawDeposit",
|
|
408
412
|
argsMapper: (params) => [params.depositId]
|
|
409
413
|
});
|
|
410
414
|
this.pruneExpiredIntents = this.buildWritableMethod({
|
|
411
|
-
abi:
|
|
415
|
+
abi: () => this.getEscrowAbi(),
|
|
412
416
|
contractResolver: () => this.getEscrowAddress(),
|
|
413
417
|
functionName: "pruneExpiredIntents",
|
|
414
418
|
argsMapper: (params) => [params.depositId]
|
|
415
419
|
});
|
|
416
420
|
this.setAcceptingIntents = this.buildWritableMethod({
|
|
417
|
-
abi:
|
|
421
|
+
abi: () => this.getEscrowAbi(),
|
|
418
422
|
contractResolver: () => this.getEscrowAddress(),
|
|
419
423
|
functionName: "setAcceptingIntents",
|
|
420
424
|
argsMapper: (params) => [params.depositId, params.accepting]
|
|
421
425
|
});
|
|
422
426
|
this.setRetainOnEmpty = this.buildWritableMethod({
|
|
423
|
-
abi:
|
|
427
|
+
abi: () => this.getEscrowAbi(),
|
|
424
428
|
contractResolver: () => this.getEscrowAddress(),
|
|
425
429
|
functionName: "setRetainOnEmpty",
|
|
426
430
|
argsMapper: (params) => [params.depositId, params.retain]
|
|
427
431
|
});
|
|
428
432
|
this.setIntentRange = this.buildWritableMethod({
|
|
429
|
-
abi:
|
|
433
|
+
abi: () => this.getEscrowAbi(),
|
|
430
434
|
contractResolver: () => this.getEscrowAddress(),
|
|
431
435
|
functionName: "setIntentRange",
|
|
432
436
|
argsMapper: (params) => [params.depositId, { min: params.min, max: params.max }]
|
|
433
437
|
});
|
|
434
438
|
this.setPaymentMethodActive = this.buildWritableMethod({
|
|
435
|
-
abi:
|
|
439
|
+
abi: () => this.getEscrowAbi(),
|
|
436
440
|
contractResolver: () => this.getEscrowAddress(),
|
|
437
441
|
functionName: "setPaymentMethodActive",
|
|
438
442
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.active]
|
|
439
443
|
});
|
|
440
444
|
this.setCurrencyMinRate = this.buildWritableMethod({
|
|
441
|
-
abi:
|
|
445
|
+
abi: () => this.getEscrowAbi(),
|
|
442
446
|
contractResolver: () => this.getEscrowAddress(),
|
|
443
447
|
functionName: "setCurrencyMinRate",
|
|
444
448
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currency, params.rate]
|
|
445
449
|
});
|
|
446
450
|
this.addCurrencies = this.buildWritableMethod({
|
|
447
|
-
abi:
|
|
451
|
+
abi: () => this.getEscrowAbi(),
|
|
448
452
|
contractResolver: () => this.getEscrowAddress(),
|
|
449
453
|
functionName: "addCurrencies",
|
|
450
|
-
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currencies]
|
|
454
|
+
argsMapper: (params) => [params.depositId, params.paymentMethod, deposit.toEscrowCurrencies(params.currencies, this.getEscrowGeneration())]
|
|
451
455
|
});
|
|
452
456
|
this.deactivateCurrency = this.buildWritableMethod({
|
|
453
|
-
abi:
|
|
457
|
+
abi: () => this.getEscrowAbi(),
|
|
454
458
|
contractResolver: () => this.getEscrowAddress(),
|
|
455
459
|
functionName: "deactivateCurrency",
|
|
456
460
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currencyCode]
|
|
457
461
|
});
|
|
458
462
|
this.addPaymentMethods = this.buildWritableMethod({
|
|
459
|
-
abi:
|
|
463
|
+
abi: () => this.getEscrowAbi(),
|
|
460
464
|
contractResolver: () => this.getEscrowAddress(),
|
|
461
465
|
functionName: "addPaymentMethods",
|
|
462
|
-
argsMapper: (params) => [params.depositId, params.paymentMethods, params.paymentMethodData, params.currencies]
|
|
466
|
+
argsMapper: (params) => [params.depositId, params.paymentMethods, params.paymentMethodData, params.currencies.map((perMethod) => deposit.toEscrowCurrencies(perMethod, this.getEscrowGeneration()))]
|
|
463
467
|
});
|
|
464
468
|
this.cancelIntent = this.buildWritableMethod({
|
|
465
469
|
abi: abis.OrchestratorAbi,
|
|
@@ -494,17 +498,61 @@ var ProveXClient = class {
|
|
|
494
498
|
});
|
|
495
499
|
}
|
|
496
500
|
// ─── Address Resolution ──────────────────────────────────────────────────
|
|
497
|
-
/**
|
|
501
|
+
/**
|
|
502
|
+
* The escrow this client acts on.
|
|
503
|
+
*
|
|
504
|
+
* Callers that touch a specific deposit MUST construct the client with
|
|
505
|
+
* `escrowAddress: deposit.escrow` — the v3 fallback below is only correct
|
|
506
|
+
* for a client that has no deposit in hand, and silently sends every write
|
|
507
|
+
* to the previous generation otherwise.
|
|
508
|
+
*/
|
|
498
509
|
getEscrowAddress() {
|
|
499
510
|
if (this.escrowOverride) return this.escrowOverride;
|
|
500
511
|
const addr = contracts.getLatestContract(this.chainId, "escrow", "v3");
|
|
501
512
|
if (!addr) throw new ProveXError("VALIDATION_ERROR", `No V3 escrow found for chain ${this.chainId}`);
|
|
502
513
|
return addr;
|
|
503
514
|
}
|
|
504
|
-
/**
|
|
515
|
+
/**
|
|
516
|
+
* The escrow's generation, used to pick the matching interface.
|
|
517
|
+
*
|
|
518
|
+
* An unrecognised address is not an error: callers may point the client at a
|
|
519
|
+
* fork or a local deployment through `escrowAddress`. Those fall back to v3,
|
|
520
|
+
* which is what this client assumed for every escrow before generations were
|
|
521
|
+
* resolved at all — so an override that worked before still works.
|
|
522
|
+
*/
|
|
523
|
+
getEscrowGeneration() {
|
|
524
|
+
return contracts.getEscrowVersion(this.getEscrowAddress(), this.chainId) ?? "v3";
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The escrow interface matching this client's escrow generation.
|
|
528
|
+
*
|
|
529
|
+
* EscrowV2 is not signature-compatible with the v3 escrow for every maker
|
|
530
|
+
* write — `createDeposit`, `addPaymentMethods` and `addCurrencies` each gain
|
|
531
|
+
* an oracle rate config in their currency tuple, which changes the selector.
|
|
532
|
+
* Binding one generation's interface to whatever address we resolved
|
|
533
|
+
* produces a call the contract cannot decode, and since these writes are not
|
|
534
|
+
* simulated the maker signs and pays gas for a certain revert.
|
|
535
|
+
*/
|
|
536
|
+
getEscrowAbi() {
|
|
537
|
+
return abis.escrowAbiByVersion[this.getEscrowGeneration()];
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Get the orchestrator address (cached after first read).
|
|
541
|
+
*
|
|
542
|
+
* Generation decides where this comes from. v2 and v3 escrows expose
|
|
543
|
+
* `orchestrator()`; EscrowV2 authorizes through an `OrchestratorRegistry`
|
|
544
|
+
* and exposes no such function, so reading it reverts and the address has to
|
|
545
|
+
* come from configuration. Probing on-chain first would therefore break
|
|
546
|
+
* every v4 flow before the wallet ever opens.
|
|
547
|
+
*/
|
|
505
548
|
async getOrchestratorAddress() {
|
|
506
549
|
if (this.cachedOrchestratorAddress) return this.cachedOrchestratorAddress;
|
|
507
550
|
const escrow = this.getEscrowAddress();
|
|
551
|
+
const configured = contracts.getConfiguredOrchestratorForEscrow(escrow);
|
|
552
|
+
if (configured) {
|
|
553
|
+
this.cachedOrchestratorAddress = configured;
|
|
554
|
+
return configured;
|
|
555
|
+
}
|
|
508
556
|
const result = await this.readContract({
|
|
509
557
|
address: escrow,
|
|
510
558
|
abi: abis.V3EscrowAbi,
|
|
@@ -993,7 +1041,7 @@ var ProveXClient = class {
|
|
|
993
1041
|
const to = await contractResolver(params);
|
|
994
1042
|
const args = argsMapper(params);
|
|
995
1043
|
const data = viem.encodeFunctionData({
|
|
996
|
-
abi,
|
|
1044
|
+
abi: typeof abi === "function" ? abi() : abi,
|
|
997
1045
|
functionName,
|
|
998
1046
|
args
|
|
999
1047
|
});
|