@provex/react 1.9.2 → 1.10.0-rc.20260912192040.fdbb8fc
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/{ProvexProvider-B51CXrDO.d.cts → ProvexProvider-DY7zWiTb.d.cts} +5 -2
- package/dist/{ProvexProvider-B51CXrDO.d.ts → ProvexProvider-DY7zWiTb.d.ts} +5 -2
- package/dist/{chunk-ORPPRRER.js → chunk-NYG43ZIX.js} +115 -79
- package/dist/chunk-NYG43ZIX.js.map +1 -0
- package/dist/index.cjs +111 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -15
- package/dist/index.d.ts +64 -15
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/wagmi.cjs +110 -74
- package/dist/wagmi.cjs.map +1 -1
- package/dist/wagmi.d.cts +1 -1
- package/dist/wagmi.d.ts +1 -1
- package/dist/wagmi.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-ORPPRRER.js.map +0 -1
package/dist/wagmi.cjs
CHANGED
|
@@ -15,6 +15,7 @@ var reputation = require('@provex/utils/reputation');
|
|
|
15
15
|
var contracts = require('@provex/utils/contracts');
|
|
16
16
|
var proving = require('@provex/proving');
|
|
17
17
|
var utils = require('@provex/utils');
|
|
18
|
+
var deposit = require('@provex/utils/deposit');
|
|
18
19
|
var fees = require('@provex/utils/fees');
|
|
19
20
|
var abis = require('@provex/abis');
|
|
20
21
|
var chain = require('@provex/utils/chain');
|
|
@@ -141,22 +142,9 @@ function getRate({
|
|
|
141
142
|
currency
|
|
142
143
|
}) {
|
|
143
144
|
if (!deposit) return 0n;
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
...Array.from(paymentConfig?.subProviders ?? []).map((sp) => sp.key)
|
|
148
|
-
];
|
|
149
|
-
let minRate = null;
|
|
150
|
-
for (const key of candidateKeys) {
|
|
151
|
-
const contractId = payment.providerKeyToContractId(key).toLowerCase();
|
|
152
|
-
const value = deposit.conversionRates.get(contractId)?.get(currency.contractId.toLowerCase());
|
|
153
|
-
if (value) {
|
|
154
|
-
if (minRate === null || value < minRate) {
|
|
155
|
-
minRate = value;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return minRate ?? 0n;
|
|
145
|
+
const contractId = payment.providerKeyToContractId(paymentMethod).toLowerCase();
|
|
146
|
+
const value = deposit.conversionRates.get(contractId)?.get(currency.contractId.toLowerCase());
|
|
147
|
+
return value ?? 0n;
|
|
160
148
|
}
|
|
161
149
|
function toDepositInfo(deposit) {
|
|
162
150
|
return {
|
|
@@ -189,11 +177,7 @@ function useDeposits(options) {
|
|
|
189
177
|
const paymentConfig = payment.providerConfigs(token.chainId)[paymentMethod];
|
|
190
178
|
return /* @__PURE__ */ new Set([
|
|
191
179
|
payment.providerKeyToContractId(paymentMethod).toLowerCase(),
|
|
192
|
-
...paymentConfig.v2Verifiers.map((v) => v.toLowerCase())
|
|
193
|
-
...Array.from(paymentConfig.subProviders).flatMap((subProvider) => [
|
|
194
|
-
payment.providerKeyToContractId(subProvider.key).toLowerCase(),
|
|
195
|
-
...subProvider.v2Verifiers(token.chainId).map((v) => v.toLowerCase())
|
|
196
|
-
])
|
|
180
|
+
...paymentConfig.v2Verifiers.map((v) => v.toLowerCase())
|
|
197
181
|
]);
|
|
198
182
|
}, [token.chainId, paymentMethod]);
|
|
199
183
|
const depositsQuery = reactQuery.useQuery({
|
|
@@ -368,82 +352,85 @@ var ProveXClient = class {
|
|
|
368
352
|
this.onSlowSync = config.onSlowSync;
|
|
369
353
|
this.apiUrl = config.apiUrl ?? defaults?.apiUrl ?? "https://app.provex.com";
|
|
370
354
|
this.createDepositRaw = this.buildWritableMethod({
|
|
371
|
-
abi:
|
|
355
|
+
abi: () => this.getEscrowAbi(),
|
|
372
356
|
contractResolver: () => this.getEscrowAddress(),
|
|
373
357
|
functionName: "createDeposit",
|
|
374
|
-
argsMapper: (params) => [
|
|
358
|
+
argsMapper: (params) => [{
|
|
359
|
+
...params,
|
|
360
|
+
currencies: params.currencies.map((perMethod) => deposit.toEscrowCurrencies(perMethod, this.getEscrowGeneration()))
|
|
361
|
+
}]
|
|
375
362
|
});
|
|
376
363
|
this.addFunds = this.buildWritableMethod({
|
|
377
|
-
abi:
|
|
364
|
+
abi: () => this.getEscrowAbi(),
|
|
378
365
|
contractResolver: () => this.getEscrowAddress(),
|
|
379
366
|
functionName: "addFunds",
|
|
380
367
|
argsMapper: (params) => [params.depositId, params.amount]
|
|
381
368
|
});
|
|
382
369
|
this.removeFunds = this.buildWritableMethod({
|
|
383
|
-
abi:
|
|
370
|
+
abi: () => this.getEscrowAbi(),
|
|
384
371
|
contractResolver: () => this.getEscrowAddress(),
|
|
385
372
|
functionName: "removeFunds",
|
|
386
373
|
argsMapper: (params) => [params.depositId, params.amount]
|
|
387
374
|
});
|
|
388
375
|
this.withdrawDeposit = this.buildWritableMethod({
|
|
389
|
-
abi:
|
|
376
|
+
abi: () => this.getEscrowAbi(),
|
|
390
377
|
contractResolver: () => this.getEscrowAddress(),
|
|
391
378
|
functionName: "withdrawDeposit",
|
|
392
379
|
argsMapper: (params) => [params.depositId]
|
|
393
380
|
});
|
|
394
381
|
this.pruneExpiredIntents = this.buildWritableMethod({
|
|
395
|
-
abi:
|
|
382
|
+
abi: () => this.getEscrowAbi(),
|
|
396
383
|
contractResolver: () => this.getEscrowAddress(),
|
|
397
384
|
functionName: "pruneExpiredIntents",
|
|
398
385
|
argsMapper: (params) => [params.depositId]
|
|
399
386
|
});
|
|
400
387
|
this.setAcceptingIntents = this.buildWritableMethod({
|
|
401
|
-
abi:
|
|
388
|
+
abi: () => this.getEscrowAbi(),
|
|
402
389
|
contractResolver: () => this.getEscrowAddress(),
|
|
403
390
|
functionName: "setAcceptingIntents",
|
|
404
391
|
argsMapper: (params) => [params.depositId, params.accepting]
|
|
405
392
|
});
|
|
406
393
|
this.setRetainOnEmpty = this.buildWritableMethod({
|
|
407
|
-
abi:
|
|
394
|
+
abi: () => this.getEscrowAbi(),
|
|
408
395
|
contractResolver: () => this.getEscrowAddress(),
|
|
409
396
|
functionName: "setRetainOnEmpty",
|
|
410
397
|
argsMapper: (params) => [params.depositId, params.retain]
|
|
411
398
|
});
|
|
412
399
|
this.setIntentRange = this.buildWritableMethod({
|
|
413
|
-
abi:
|
|
400
|
+
abi: () => this.getEscrowAbi(),
|
|
414
401
|
contractResolver: () => this.getEscrowAddress(),
|
|
415
402
|
functionName: "setIntentRange",
|
|
416
403
|
argsMapper: (params) => [params.depositId, { min: params.min, max: params.max }]
|
|
417
404
|
});
|
|
418
405
|
this.setPaymentMethodActive = this.buildWritableMethod({
|
|
419
|
-
abi:
|
|
406
|
+
abi: () => this.getEscrowAbi(),
|
|
420
407
|
contractResolver: () => this.getEscrowAddress(),
|
|
421
408
|
functionName: "setPaymentMethodActive",
|
|
422
409
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.active]
|
|
423
410
|
});
|
|
424
411
|
this.setCurrencyMinRate = this.buildWritableMethod({
|
|
425
|
-
abi:
|
|
412
|
+
abi: () => this.getEscrowAbi(),
|
|
426
413
|
contractResolver: () => this.getEscrowAddress(),
|
|
427
414
|
functionName: "setCurrencyMinRate",
|
|
428
415
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currency, params.rate]
|
|
429
416
|
});
|
|
430
417
|
this.addCurrencies = this.buildWritableMethod({
|
|
431
|
-
abi:
|
|
418
|
+
abi: () => this.getEscrowAbi(),
|
|
432
419
|
contractResolver: () => this.getEscrowAddress(),
|
|
433
420
|
functionName: "addCurrencies",
|
|
434
|
-
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currencies]
|
|
421
|
+
argsMapper: (params) => [params.depositId, params.paymentMethod, deposit.toEscrowCurrencies(params.currencies, this.getEscrowGeneration())]
|
|
435
422
|
});
|
|
436
423
|
this.deactivateCurrency = this.buildWritableMethod({
|
|
437
|
-
abi:
|
|
424
|
+
abi: () => this.getEscrowAbi(),
|
|
438
425
|
contractResolver: () => this.getEscrowAddress(),
|
|
439
426
|
functionName: "deactivateCurrency",
|
|
440
427
|
argsMapper: (params) => [params.depositId, params.paymentMethod, params.currencyCode]
|
|
441
428
|
});
|
|
442
429
|
this.addPaymentMethods = this.buildWritableMethod({
|
|
443
|
-
abi:
|
|
430
|
+
abi: () => this.getEscrowAbi(),
|
|
444
431
|
contractResolver: () => this.getEscrowAddress(),
|
|
445
432
|
functionName: "addPaymentMethods",
|
|
446
|
-
argsMapper: (params) => [params.depositId, params.paymentMethods, params.paymentMethodData, params.currencies]
|
|
433
|
+
argsMapper: (params) => [params.depositId, params.paymentMethods, params.paymentMethodData, params.currencies.map((perMethod) => deposit.toEscrowCurrencies(perMethod, this.getEscrowGeneration()))]
|
|
447
434
|
});
|
|
448
435
|
this.cancelIntent = this.buildWritableMethod({
|
|
449
436
|
abi: abis.OrchestratorAbi,
|
|
@@ -478,17 +465,66 @@ var ProveXClient = class {
|
|
|
478
465
|
});
|
|
479
466
|
}
|
|
480
467
|
// ─── Address Resolution ──────────────────────────────────────────────────
|
|
481
|
-
/**
|
|
468
|
+
/**
|
|
469
|
+
* The escrow this client acts on.
|
|
470
|
+
*
|
|
471
|
+
* Callers that touch a specific deposit MUST construct the client with
|
|
472
|
+
* `escrowAddress: deposit.escrow` — the fallback below is only correct for a
|
|
473
|
+
* client that has no deposit in hand, and silently sends every write to the
|
|
474
|
+
* wrong escrow otherwise.
|
|
475
|
+
*
|
|
476
|
+
* That fallback follows the chain's current generation rather than a pinned
|
|
477
|
+
* v3. The only writes that reach it are ones with no existing deposit to
|
|
478
|
+
* name — `createDeposit` above all — and those belong on the generation the
|
|
479
|
+
* protocol is actually running, not the one it has moved off.
|
|
480
|
+
*/
|
|
482
481
|
getEscrowAddress() {
|
|
483
482
|
if (this.escrowOverride) return this.escrowOverride;
|
|
484
|
-
const addr = contracts.getLatestContract(this.chainId, "escrow",
|
|
485
|
-
if (!addr) throw new ProveXError("VALIDATION_ERROR", `No
|
|
483
|
+
const addr = contracts.getLatestContract(this.chainId, "escrow", contracts.getLatestConfiguredVersion(this.chainId));
|
|
484
|
+
if (!addr) throw new ProveXError("VALIDATION_ERROR", `No escrow configured for chain ${this.chainId}`);
|
|
486
485
|
return addr;
|
|
487
486
|
}
|
|
488
|
-
/**
|
|
487
|
+
/**
|
|
488
|
+
* The escrow's generation, used to pick the matching interface.
|
|
489
|
+
*
|
|
490
|
+
* An unrecognised address is not an error: callers may point the client at a
|
|
491
|
+
* fork or a local deployment through `escrowAddress`. Those fall back to v3,
|
|
492
|
+
* which is what this client assumed for every escrow before generations were
|
|
493
|
+
* resolved at all — so an override that worked before still works.
|
|
494
|
+
*/
|
|
495
|
+
getEscrowGeneration() {
|
|
496
|
+
return contracts.getEscrowVersion(this.getEscrowAddress(), this.chainId) ?? "v3";
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* The escrow interface matching this client's escrow generation.
|
|
500
|
+
*
|
|
501
|
+
* EscrowV2 is not signature-compatible with the v3 escrow for every maker
|
|
502
|
+
* write — `createDeposit`, `addPaymentMethods` and `addCurrencies` each gain
|
|
503
|
+
* an oracle rate config in their currency tuple, which changes the selector.
|
|
504
|
+
* Binding one generation's interface to whatever address we resolved
|
|
505
|
+
* produces a call the contract cannot decode, and since these writes are not
|
|
506
|
+
* simulated the maker signs and pays gas for a certain revert.
|
|
507
|
+
*/
|
|
508
|
+
getEscrowAbi() {
|
|
509
|
+
return abis.escrowAbiByVersion[this.getEscrowGeneration()];
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Get the orchestrator address (cached after first read).
|
|
513
|
+
*
|
|
514
|
+
* Generation decides where this comes from. v2 and v3 escrows expose
|
|
515
|
+
* `orchestrator()`; EscrowV2 authorizes through an `OrchestratorRegistry`
|
|
516
|
+
* and exposes no such function, so reading it reverts and the address has to
|
|
517
|
+
* come from configuration. Probing on-chain first would therefore break
|
|
518
|
+
* every v4 flow before the wallet ever opens.
|
|
519
|
+
*/
|
|
489
520
|
async getOrchestratorAddress() {
|
|
490
521
|
if (this.cachedOrchestratorAddress) return this.cachedOrchestratorAddress;
|
|
491
522
|
const escrow = this.getEscrowAddress();
|
|
523
|
+
const configured = contracts.getConfiguredOrchestratorForEscrow(escrow);
|
|
524
|
+
if (configured) {
|
|
525
|
+
this.cachedOrchestratorAddress = configured;
|
|
526
|
+
return configured;
|
|
527
|
+
}
|
|
492
528
|
const result = await this.readContract({
|
|
493
529
|
address: escrow,
|
|
494
530
|
abi: abis.V3EscrowAbi,
|
|
@@ -638,34 +674,16 @@ var ProveXClient = class {
|
|
|
638
674
|
}
|
|
639
675
|
/**
|
|
640
676
|
* Convert human-readable deposit params to raw contract params.
|
|
641
|
-
* Handles
|
|
677
|
+
* Handles rail collapsing, hashing, gating service encoding, and defaults.
|
|
642
678
|
*/
|
|
643
679
|
buildCreateDepositRawParams(params) {
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
expanded.push({
|
|
652
|
-
providerKey: sub.key,
|
|
653
|
-
payeeDetailsHash: hash,
|
|
654
|
-
currencies: pm.currencies,
|
|
655
|
-
intentGatingService: pm.intentGatingService,
|
|
656
|
-
data: pm.data
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
} else {
|
|
660
|
-
expanded.push({
|
|
661
|
-
providerKey: pm.provider,
|
|
662
|
-
payeeDetailsHash: hash,
|
|
663
|
-
currencies: pm.currencies,
|
|
664
|
-
intentGatingService: pm.intentGatingService,
|
|
665
|
-
data: pm.data
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
}
|
|
680
|
+
const collapsed = params.paymentMethods.map((pm) => ({
|
|
681
|
+
providerKey: payment.resolveRailProviderKey(pm.provider),
|
|
682
|
+
payeeDetailsHash: payment.computePayeeDetailsHash(pm.payeeId),
|
|
683
|
+
currencies: pm.currencies,
|
|
684
|
+
intentGatingService: pm.intentGatingService,
|
|
685
|
+
data: pm.data
|
|
686
|
+
}));
|
|
669
687
|
const defaultGatingData = viem.encodeAbiParameters(
|
|
670
688
|
viem.parseAbiParameters(["address[]"]),
|
|
671
689
|
[[contracts.reclaimSigners.peerWitnessSigner, contracts.reclaimSigners.reclaimWitnessSigner]]
|
|
@@ -678,13 +696,13 @@ var ProveXClient = class {
|
|
|
678
696
|
min: params.intentRange?.min ?? 1000000n,
|
|
679
697
|
max: params.intentRange?.max ?? params.amount
|
|
680
698
|
},
|
|
681
|
-
paymentMethods:
|
|
682
|
-
paymentMethodData:
|
|
699
|
+
paymentMethods: collapsed.map((p) => payment.providerKeyToContractId(p.providerKey)),
|
|
700
|
+
paymentMethodData: collapsed.map((p) => ({
|
|
683
701
|
intentGatingService: p.intentGatingService ?? defaultGatingService,
|
|
684
702
|
payeeDetails: p.payeeDetailsHash,
|
|
685
703
|
data: p.data ?? defaultGatingData
|
|
686
704
|
})),
|
|
687
|
-
currencies:
|
|
705
|
+
currencies: collapsed.map(
|
|
688
706
|
(p) => p.currencies.map((c) => ({
|
|
689
707
|
code: currencies.tickerToContractId(c.code),
|
|
690
708
|
minConversionRate: c.minRate
|
|
@@ -995,7 +1013,7 @@ var ProveXClient = class {
|
|
|
995
1013
|
const to = await contractResolver(params);
|
|
996
1014
|
const args = argsMapper(params);
|
|
997
1015
|
const data = viem.encodeFunctionData({
|
|
998
|
-
abi,
|
|
1016
|
+
abi: typeof abi === "function" ? abi() : abi,
|
|
999
1017
|
functionName,
|
|
1000
1018
|
args
|
|
1001
1019
|
});
|
|
@@ -1462,16 +1480,34 @@ function useOrchestratorAddress({
|
|
|
1462
1480
|
chainId,
|
|
1463
1481
|
enabled = true
|
|
1464
1482
|
}) {
|
|
1465
|
-
|
|
1483
|
+
const configuredOrchestrator = react.useMemo(
|
|
1484
|
+
() => escrowAddress ? contracts.getConfiguredOrchestratorForEscrow(escrowAddress) : null,
|
|
1485
|
+
[escrowAddress]
|
|
1486
|
+
);
|
|
1487
|
+
const query = useContractRead({
|
|
1466
1488
|
address: escrowAddress,
|
|
1467
1489
|
abi: abis.V3EscrowAbi,
|
|
1468
1490
|
functionName: "orchestrator",
|
|
1469
1491
|
chainId,
|
|
1470
1492
|
query: {
|
|
1471
|
-
enabled: enabled && !!escrowAddress,
|
|
1493
|
+
enabled: enabled && !!escrowAddress && !configuredOrchestrator,
|
|
1472
1494
|
staleTime: Infinity
|
|
1473
1495
|
}
|
|
1474
1496
|
});
|
|
1497
|
+
return react.useMemo(() => {
|
|
1498
|
+
if (!configuredOrchestrator) return query;
|
|
1499
|
+
return {
|
|
1500
|
+
...query,
|
|
1501
|
+
data: configuredOrchestrator,
|
|
1502
|
+
isLoading: false,
|
|
1503
|
+
isPending: false,
|
|
1504
|
+
isFetching: false,
|
|
1505
|
+
isSuccess: true,
|
|
1506
|
+
isError: false,
|
|
1507
|
+
error: null,
|
|
1508
|
+
status: "success"
|
|
1509
|
+
};
|
|
1510
|
+
}, [query, configuredOrchestrator]);
|
|
1475
1511
|
}
|
|
1476
1512
|
var FEE_CACHE_STALE_TIME = 60 * 60 * 1e3;
|
|
1477
1513
|
function useProtocolFees({
|
|
@@ -1786,7 +1822,7 @@ function useProvexBuy({
|
|
|
1786
1822
|
);
|
|
1787
1823
|
const attestationBaseUrl = config.apiUrl;
|
|
1788
1824
|
const verifyingContract = react.useMemo(
|
|
1789
|
-
() => contracts.
|
|
1825
|
+
() => contracts.getPaymentAttestationVerifier(chainId),
|
|
1790
1826
|
[chainId]
|
|
1791
1827
|
);
|
|
1792
1828
|
const captureRequest = react.useMemo(() => {
|